Default Android Studio Navigation Drawer Activity Template does not show Hamburger Icon, only arrow icon

4.3k views Asked by At

This person is basically running into the same problem I'm having, however, the provided solution is not helpful, nor does it work for me since my code is in fact calling mDrawerToggle.sycnState() (in a deferred Runnable).

I've also tried adding it to onActivityCreated in my Fragment, which doesn't seem to do anything. Not knowing exactly what syncState does, I can't tell if it's syncing the state of being open (which the template code makes happen by default), and then it never is synced again when the drawer is manually closed.

I'd post code but you can test this by making a new project in Android Studio (1.2.2), selecting the Navigation Drawer Activity, and then simply running the project - no changes necessary. You'll see that the only icon is ever the <- arrow. I've even set breakpoints to inspect the ActionBarDrawerToggle object which in fact has the hamburger icon in its memory for the icon to draw, flummoxing me even more!

I'm at my wits end here.

1

There are 1 answers

0
Enuratique On

I just figured out a solution in case anyone else is having this problem:

Change the import at the top of the fragment from

import android.support.v4.app.ActionBarDrawerToggle;

to

import android.support.v7.app.ActionBarDrawerToggle;

then change the code in setUp from

mDrawerToggle = new ActionBarDrawerToggle(
            getActivity(),                    /* host Activity */
            mDrawerLayout,                    /* DrawerLayout object */
            R.drawable.ic_drawer,             /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
    )

to

mDrawerToggle = new ActionBarDrawerToggle(
            getActivity(),                    /* host Activity */
            mDrawerLayout,                    /* DrawerLayout object */
            R.string.navigation_drawer_open,  /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close  /* "close drawer" description for accessibility */
    )