Android-Open导航抽屉只需点击AppIcon即可

时间:2014-02-06 21:37:38

标签: java android android-layout navigation-drawer

有一种方法可以通过滑动禁用导航抽屉打开? 我有一个轻扫以解除ListView,有时用户触发navigationDrawer,而他想要删除列表中的项目。 感谢。

3 个答案:

答案 0 :(得分:1)

使用 mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

答案 1 :(得分:1)

这应该可以解决问题

mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

答案 2 :(得分:0)

如果你想通过滑动防止抽屉被打开并正常关闭这就是诡计!

       // 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();

棘手的部分是,你应该在它关闭时锁定抽屉,并在它打开时再次解锁!