简体   繁体   中英

How can the ActionBarDrawerToggle be hidden upon user logout?

I am new to Android development. I want to allow the drawer to be shown and used for navigation when a user is logged in, but hidden when the user logs out. How can this be done? It is currently set to close the drawer and set listener to null, but that just changes the toggle button to an arrow. Thanks!

DrawerLayout drawer = (DrawerLayout) this.findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
        this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
drawer.setDrawerListener(null);
drawer.closeDrawer(Gravity.LEFT); 

在进一步检查之后,以下内容使我可以隐藏ActionBarDrawerToggle:

toolbar.setNavigationIcon(null); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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