问题描述
我已经做了双抽屉布局的没有动作条是这样的:
I have made a double drawer layout without an actionbar something like this:
Using抽屉式导航栏没有TitleBar中或动作条
我的要求是,以禁用右边的抽屉时,左边抽屉是打开和放大器;反之亦然。所以我躲右抽屉按钮时留下的抽屉被打开和放大器;反之亦然,并且工作正常。
My requirement is to disable the drawer on right when drawer on left is open & vice versa. So I'm hiding the right drawer button when left drawer is open & vice versa and that works fine.
但问题是,即使我隐藏按钮(左或右),出票人仍与横向滑动(从右到左轻扫)打开。 因此,我怎么prevent从轻扫开抽屉??
But the problem is, even when I hide a button(left or right), the drawer still opens with horizontal swipe(right to left swipe). So how do I prevent the drawer from opening from swipe??
既然我做的没有ActionBarDrawerToggle内置功能,如
And since I'm doing it without ActionBarDrawerToggle inbuilt functions like
setOnDrawerOpenListener
setOnDrawerCloseListener
不可用。
请帮助!
推荐答案
这可能会帮助你...
this may help you...
drawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
@Override
public void onDrawerStateChanged(int arg0) {
}
@Override
public void onDrawerSlide(View view, float arg1) {
}
@Override
public void onDrawerOpened(View view) {
if(view == rightDrawerView) {
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, leftDrawerView);
} else if(view == leftDrawerView) {
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, rightDrawerView);
}
}
@Override
public void onDrawerClosed(View view) {
if(view == rightDrawerView) {
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, leftDrawerView);
} else if(view == leftDrawerView) {
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, rightDrawerView);
}
}
});
这篇关于如何从一个侧面禁用抽屉布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!