Reputation: 185
There is a way to disable the navigation drawer to open with a swipe? I have a Swipe to dismiss ListView and sometimes the user trigger the navigationDrawer while he want to delet an item of the list. Thanks.
Upvotes: 0
Views: 221
Reputation: 5236
if you want to prevent the drawer to be opened by swipe and close normally This Is the Trick!
// Drawer Layout
final DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar,R.string.hello_world, R.string.action_settings){
@Override
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
Log.d("here","close");
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
}
@Override
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
Log.d("here","open");
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED);
}
};
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
toggle.setDrawerIndicatorEnabled(true);
drawerLayout.setDrawerListener(toggle);
toggle.syncState();
the tricky part is, you should lock the drawer when it is close and unlock it again when it is open!
Upvotes: 0
Reputation: 3864
this should do the trick
mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
Upvotes: 1
Reputation: 593
use mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
Upvotes: 1