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

1

6

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.

Navaho answered 12/6, 2015 at 16:48 Comment(1)
Use this #30773129Boeschen
N
20

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 */
    )
Navaho answered 12/6, 2015 at 17:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.