Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 755
Harsha M V Avatar asked May 22 '13 13:05

Harsha M V


People also ask

Where is the navigation drawer on my Android phone?

The navigation drawer is a UI panel that shows your app's main navigation menu. The drawer appears when the user touches the drawer icon in the app bar or when the user swipes a finger from the left edge of the screen.

How do I customize my navigation drawer?

Android App Development for BeginnersStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main. xml. Step 3 − Add the following code to res/layout/nav_header_main.


Video Answer


1 Answers

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.

like image 126
Nick Avatar answered Oct 30 '22 06:10

Nick