Android: Disable/Lock NavigationDrawer

I just had the situation where I wanted to disable the NavigationDrawer from within a fragment. So the user is forced to do something and can’t switch to another view. I did a bit of research and found the following method in the android api docs:

drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

Now the NavigationDrawer is locked. Of course there is another LockMode that you can set to unlock the NavigatioDrawer again:

DrawerLayout.LOCK_MODE_UNLOCKED

Yannick Signer

 

Leave a Reply

Your email address will not be published. Required fields are marked *