Android Navigation Drawer
I was trying to explore the new navigation drawer that is standardized by Google. Finally we have the official code as well.
I was trying to understand the best way to implement the same in my app.
My Structure of the app is as follows
-MainActivity
----Featured Tab
----Favorites Tab
On Clicking of any Element in either Tab it will take me below
ContentActivity
----Info Tab
----Map Tab
Now what i am confused is all the above has to be placed into the new View for the Nav Drawer.
And As the Nav Drawer Structure is something like this
An Activity with a layout which contains navdraw-view and intern it contains content-layout and drawer layout. On clicking an option in the drawer should i replace the content layout all together or should i open a new Activity ?
As detailed in the documentation for Creating a Navigation Drawer under "Handle Navigation Click Events", it works using Fragments. When the user chooses an option you only replace the content Fragment, allowing the navigation drawer to stay where it is. If you follow the documentation then you should be fine.
If you've not yet encountered Fragments then it would be worth reading up on them in the documentation for Fragments. They're sort of like activities, with a few differences to allow Android to show multiple fragments at a time.
The answer is that you could do either, you could switch out the content, with a new Fragment, or launch a new Activity.
You are free to do whatever you want in the selectItem(position) method.
The official documentation uses Fragments in their example, but it is not required. You can do anything you want in this method (just start with a Toast, or Logcat message, to see what happens when the element is clicked).
链接地址: http://www.djcxy.com/p/71602.html上一篇: Java类常量池重复?
下一篇: Android导航抽屉