I am currently learning about the Navigation Drawer from the android site, and I am using their example http://developer.android.com/training/implementing-navigation/nav-drawer.html
What I want is to add a button in the MainActivity
which would be able to open the NavigationDrawer
. I need to do it programmatically, not in XML. How can I do that?
Best Answer
Create a method in
MainActivity
which contains your drawerLayout.and from Your fragment In oncreateView() method As you want new Button Programmatically add Button in Your Root inflated layout. Your fragment has button
bellow I modified fragment try
You can try this code in your fragment..