20

I'm trying to implement the new NavigationDrawer provided since the last Android keynote.

I got everything up and running, the navigation drawer opens and closes when pressing on the icon on the top left corner.

But now I still have the arrow icon although I replaced it with the ic_drawer from Android. Why?

Here's my code where I specified the icon:

mDrawerToggle = new ActionBarDrawerToggle(
            this,                 
            mDrawerLayout,         
            R.drawable.ic_drawer, //<-- This is the icon provided by Google itself
            R.string.drawer_open,
            R.string.drawer_close 
            )

But the application still runs with the standard icon of setDisplayHomeAsUpEnabled.

Any ideas?

Michael Currie
  • 13,721
  • 9
  • 42
  • 58
user2410644
  • 3,861
  • 6
  • 39
  • 59

2 Answers2

48

I just got the Navigation Drawer working. I had forgotten to add following methods also provided by the developer.android.com examples:

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    // Sync the toggle state after onRestoreInstanceState has occurred.
    mDrawerToggle.syncState();
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    mDrawerToggle.onConfigurationChanged(newConfig);
}
Michael Currie
  • 13,721
  • 9
  • 42
  • 58
user2410644
  • 3,861
  • 6
  • 39
  • 59
  • 1
    This was it exactly! Thank you! I was looking for like 2 hours for a solution. – Kyle Falconer Jun 27 '13 at 21:38
  • 2
    I have the same problem, but just with older devices, like 2.3. My code was already like yours and the problem keeps disturbing me.. – Renan Bandeira Nov 07 '13 at 23:46
  • 1
    So those times when you're following an official Google example and say, "Oh, I don't need implement those functions yet". Yeah, don't do that. Thanks for this answer! – theblang Dec 10 '13 at 20:46
2

I had the same problem the answer is if you are setting

getActionBar().setDisplayShowHomeEnabled(false);

then the normal up icon is shown. So try without using it

Ravi
  • 4,872
  • 8
  • 35
  • 46