Reputation: 8335
I would like to create an user interface that always displays a menu panel on the left side, and a content block which changes depending on which menu entry is selected, i.e something similar to many websites.
I am new to creating Android user interfaces so I am wondering how to properly and dynamically change the content.
Is it better to create two different views, each of them including the same panel fragment (meaning 2 instances ?) and a different content fragment, and change that view using Activity#setContentView()
, or should I create a single view and replace the fragment of the content dynamically ?
Upvotes: 0
Views: 63
Reputation: 1215
Use this below code with library from github it will answar you perfectly https://github.com/neokree/MaterialNavigationDrawer
Upvotes: 0
Reputation: 768
You should definitely use the Fragment approach.
Use a FragmentActivity and use the FragmentManager (getFragmentManager in the Activity) to create a transition and replace the Fragment depending on what item the user clicked.
See: http://developer.android.com/training/basics/fragments/fragment-ui.html
Upvotes: 1