Reputation: 1
Upvotes: 0
Views: 668
Reputation:
Use this: ((YourActivityWithDrawer)getActivity()).drawerLayout.openDrawer(your_drawer);
where:
YourActivityWithDrawer
is your Activity containing drawer,
drawerLayout
is your DrawerLayout object
your_drawer
is the actual drawer object.
Upvotes: 0
Reputation: 505
there is one solution you can set the image as action bar app icon and you can open drawer on click of that image-
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
this line of code will Enable ActionBar app icon to behave as action to toggle navigation drawer
Upvotes: 0
Reputation: 1586
Do this in onClick of imageView:
if(drawer.isOpened()){ drawer.closeDrawer(your_drawer_view);}
else drawer.openDrawer(your_drawer_view);
Upvotes: 0
Reputation: 66
To open the NavigationDrawer use this :-
mDrawerLayout.openDrawer(Gravity.LEFT);
To close the NavigationDrawer use this :-
mDrawerLayout.closeDrawer(Gravity.LEFT);
Upvotes: 1