In this tutorial we’ll implement a Navigation Drawer in our android application. Android navigation drawer is a sliding menu and it’s an important UI component. You will see navigation drawer in most of the android applications, it’s like navigation menu bars in the websites.
If you want to add Navigation Drawer Activity to your existing project you can simply add it by going to your package -> right click -> new -> activity -> navigation drawer activity
This is the simplest way for creating a navigation drawer activity.
Navigation Drawer Menus
To change the menu open the activity_main_drawer.xml inside menu folder.
This is my activity_main_drawer.xml
Try changing the values and run.
Open you activity which has the Drawer in it. It will contain a method like this.
[alert type=blue ]
Changing Screens using Fragments for each MenuItem
For Simplicity, I am creating a Fragment for all the Menu Items which has a layout with only a TextView.
We will add a FrameLayout inside the content_home.xml for adding and replacing Fragments.
Adding Screens for each Menu
Display First Screen
To Display the first screen we will add the first fragment in the onCreate of the Activity.
[alert type=white ]All Done. Check out the source code on my github account[/alert]
Please send your valuable comments below regarding the post.
Tweets on Twitter
Code on Github
Subscribe to my Youtube Channel