我正在构建一个应用程序,我想在其中显示一些其他信息,但是在单击导航抽屉内部后,默认情况下它会关闭,我希望它保持打开状态,直到用户单击导航抽屉外部或按后退按钮
这可能吗?我该如何实现它?如果不是,我如何在不使用导航视图的情况下实现它
我尝试使用: mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN(; 在我的 onCreate 和 onNavigationItemSelected ...默认情况下,在onCreate上使用它会打开导航抽屉,使我无法关闭它
这是我的抽屉侦听器代码;
DrawerLayout drawer = findViewById(R.id.drawer_layout);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
DrawerLayout drawerLayout; // Global variable
drawerLayout = findViewById(R.id.drawer_layout);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
drawerLayout.openDrawer(GravityCompat.START); // Use this line of code where you want to keep open the drawerLayout.
如果您仍有问题需要理解,请告诉我。