-2

I'm currently trying to change the icon in Navigation Drawer when some event occurs. Is it possible?? I mean that I change the icon - it's no problem:

    mDrawerToggle = new ActionBarDrawerToggle(
            this,                  
            mDrawerLayout,         
            R.drawable.actionbar_settings,  /* my icon - all Ok! */
            R.string.text1,  
            R.string.text2  
    ) {};

I mean what to do if some event fires and I want to change this icon on another? If I repeat the code but with another icon - no success.

    mDrawerToggle = new ActionBarDrawerToggle(
            this,                  
            mDrawerLayout,         
            R.drawable.new_icon_image,  /* bad news - nothing changes */
            R.string.text1,  
            R.string.text2  
    ) {};

Thanks a lot!

user3534709
  • 33
  • 1
  • 6

1 Answers1

1

Is it possible?

Yes, but you'll need to call DrawerLayout.setDrawerListener and ActionBarDrawerToggle.syncState to update the indicator and make sure it's synced.

Here's an example:

mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
        R.drawable.new_icon_image, R.string.text1, R.string.text2);
mDrawerLayout.setDrawerListener(mDrawerToggle);
mDrawerToggle.syncState();
adneal
  • 30,484
  • 10
  • 122
  • 151
  • @user3534709 If you're satisfied with the answer, [will you mark it as accepted, please?](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work/5235#5235) – adneal Apr 24 '14 at 22:06
  • Vote up requires 15 reputation :( – user3534709 Apr 27 '14 at 14:24