简体   繁体   English

Android导航抽屉将滑动锁定在片段中不起作用

[英]Android navigation drawer locking the swipe in fragment not working

Hi am facing a strange issue. 您好,面临一个奇怪的问题。 I am trying to lock the swipe of navigation drawer in a fragment like below 我正在尝试将导航抽屉的滑动锁定在如下片段中

 @Override
    public void onResume() {
        super.onResume();
        MainActivity.mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
    }

The above code working fine when the fragment loads. 片段加载时,上面的代码可以正常工作。 But when in that fragment am opening the keyboard and entering some text in edittext and closing the keyboard the swipe is auto enable, which should not happen. 但是,当在该片段中打开键盘并在edittext中输入一些文本,然后关闭键盘时,滑动会自动启用,这不会发生。 Not sure why the keyboard open and close is enabling the navigation drawer swipe. 不确定为什么打开和关闭键盘会导致导航抽屉滑动。

Try this 尝试这个

    DrawerLayout mDrawerLayout = (DrawerLayout)getActivity().findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM