androiddrawerlayoutactionbardrawertoggle

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

Solution

  • After checking into this further, the following allowed me to hide the ActionBarDrawerToggle:

    toolbar.setNavigationIcon(null);