The home screen is one of the Fragments and the Activity is not visible. So far I have adapted the Navigation Drawer template so that there is just the one MainActivity.java file with 5 Fragments, each with a unique Fragment.java and ViewModel.java file and a layout.xml file per Fragment. Does the Activity actually need to be one of the visible screen like the home screen (as it would be in an app without Fragments) or is it just there behind the scenes providing the functionality for the Fragments according to what java code I put in the Fragments and Activity java files? I understand that you need an Activity to underpin the Fragments. If this is the case, what would I put in the Fragment java file rather than the ViewModel java file?Ģ) The template also provides a second home Fragment, I'm really not sure why? Any explanation for that? (I don't think I need this.)ģ) As I'm completely new to Android Fragments (I think I understand how to work with just Activities), could someone please explain the role of the single Activity in the the Navigation Drawer template project? I'm trying to understand if this is the way Fragments are usually structured with a separate java file for the actual content of a Fragment screen. Easy handling and implementation of Navigation UI patterns such as Navigation Drawer. Easy handling and implementation of deep linking. Provides standardized animation and transitions while switching the content of the NavHost. Handling Up and back actions, basically handling the Backstack. I am teaching myself to use Android for an app for my final year BSc computing project with the Open University (UK).ġ) Why does the Navigation Drawer template project include both ViewModel java files for each of the Fragments as well as fragment java files? Navigation Component handles the Fragment transaction. My question is an architectural question about Android Studio's Navigation Drawer template project files.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |