2

UPDATE: I have found the hamburger icon from google's github (https://github.com/google/material-design-icons/blob/master/navigation/drawable-xxhdpi/ic_menu_white_48dp.png) but passing the drawable resource to the ActionBarDrawerToggle and calling syncState doesn't show the hamburger icon contrary to other post's suggestions (Appcompatv7 - v21 Navigation drawer not showing hamburger icon)

OLD QUESTION: I was making a navigation bar for my android app and I realized that the hamburger icon was missing. I followed this question (Appcompatv7 - v21 Navigation drawer not showing hamburger icon) and realized that I must call a mDrawerToggle.syncState();... Now to create an ActionBarDrawerToggleclass I need the following:

  • activity - The Activity hosting the drawer
  • drawerLayout - The DrawerLayout to link to the given Activity's ActionBar
  • drawerImageRes - A Drawable resource to use as the drawer indicator
  • openDrawerContentDescRes - A String resource to describe the "open drawer" - action for accessibility
  • closeDrawerContentDescRes - A String resource to describe the "close drawer" action for accessibility

I passed in this as the activity (I'm calling this from my main activity), drawerLayout as my actual drawer layout and the docs weren't really explaining what the last two params do so I just created some placeholder string resources and passed them in. But I do understand that the drawerImageRes is required to show the hamburger icon, I just don't know where to get it form..

Can anyone tell me where I can get the hamburger icon?

EDIT: I figured out that the android example from https://developer.android.com/training/implementing-navigation/nav-drawer.html uses R.drawable.ic_drawer but I don't know where it's come from... The android developer website also says:

The standard navigation drawer icon is available in the Download the Action Bar Icon Pack.

But I downloaded the pack and the lollipop hamburger isn't there...

Community
  • 1
  • 1
Anshu Dwibhashi
  • 4,617
  • 3
  • 28
  • 59

1 Answers1

2

If you update your support library to v22, and

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 */
    )

do something similar to this, the hamburger icon will show up. I had a problem similar to this but now it's fixed thanks to a really helpful person.

silverAndroid
  • 960
  • 3
  • 11
  • 29
  • Awesome! Thats works for me. I have to update the package from `v4` to `v7` and then i get the right contructor. – Manu Zi Aug 22 '15 at 09:28
  • That worked for me, Android Studio's wizard provide an obsolete code with an `ActionBarDrawerToggle` from `appcompatv4`. I just have to change the import to `v7` and the constructor. – Solostaran14 Oct 26 '15 at 16:38