The easiest way to see fragments in action is to create a new application and use the Master / Detail Flow. It has it’s own life cycle, deals with it’s own inputs, and each activity can contain multiple fragments. A fragment is a way of composing a part of an activity. The solution they came up with was Fragments. 3.X was never officially released to run on phones, but they started thinking about how to make page constructs that weren’t just in the form of activities tied to layouts. When Android moved from 2.X to 3.X, they were moving from only focusing on phone form factors to also tablets. This doesn’t really mesh with the nav drawer though as you’d have to have the same nav drawer on several activities Enter the Fragment In earlier days of Android development the way you got from one page to another was to have several Activities and to use an intent to launch each new activity. What you won’t see though, is how to actually navigate between different “content pages” when you tap the different menu options in the nav drawer! If you are familiar with some Android development, this might be a bit surprising. If you go into Android Studio right now and create a new application and base it off the Navigation Drawer Activity, you’ll get a very basic app with a single activity and the nav drawer will be set up fairly similarly to what you see above. Instead of starting a new activity where the user has to go back (via the back button or a back button in the top left of the screen), the navigation drawer (usually via the familiar hamburger button) stays available as you go from one area of the app to others (it seems like it’s common for a few pages to launch and require the back button such as Settings and Help). Typically, when the user taps one of the items on the menu, the content page is reloaded. The Navigation Drawer is a slide out menu that enables users to navigate around the different areas of the application. If you’ve used an Android device, you’ve almost certainly seen and used this design pattern: The primary means of navigation in the app was going to be a Navigation Drawer. I’ve been working on a new Android application and just recently ran into a problem that I was surprised didn’t have a clearer solution. TLDR: If you want to grab the sample code, it’s available on GitHub.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |