24

I'm using Appcompat v22 to use tinted style for AutoCompleteTextView. However, as soon as I changed my build.gradle from this:

compile 'com.android.support:support-v4:21.0.3'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:cardview-v7:21.0.2'
compile 'com.android.support:recyclerview-v7:21.0.2'

to this:

compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:gridlayout-v7:22.0.0'
compile 'com.android.support:cardview-v7:22.0.0'

The ActionBarDrawerToggle Icon (Hamburger icon) goes missing. (However, if I slide from left, the drawer gets revealed)

Inside onCreate():

    mDrawerLayout = (BBDrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
            R.string.drawer_open, R.string.drawer_close) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            toolbar.setTitle(mTitle);
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            trackEvent(TrackingAware.MENU_SHOWN, null);
            toolbar.setTitle(mDrawerTitle);
            invalidateOptionsMenu();
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

Have also called syncState()

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    if (mDrawerToggle != null) {
        mDrawerToggle.syncState();
    }
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
    if (mDrawerToggle != null) {
        mDrawerToggle.onConfigurationChanged(newConfig);
    }
}

If I downgrade the appcompat version back to 21.0.3, everything starts to work.

Siddharth Srivastava
  • 1,059
  • 1
  • 10
  • 22

3 Answers3

20

The relevant part is in the last line of code, I have them in my Activity.onCreate(..) method:

    _drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, 0, 0);
    drawerLayout.setDrawerListener(_drawerToggle);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

As I remember that line is documented too but in appcompat v21 they were ignored (or at least the default was different..)

Gianluca P.
  • 1,536
  • 15
  • 15
  • 1
    I'm having this same problem. The only thing that seems to make the home button show up is calling setDisplayHomeAsUpEnabled(true). When I do that, I see the hamburger icon, and when I click it, it acts as the back button. I'm thoroughly confused. – M Dapp May 19 '15 at 20:16
  • This doesn't seem to solve it for me. I'm already calling: getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); – waterlooalex May 30 '15 at 18:20
  • Figured it out, I was using v4 AppCompat ActionBarDrawerToggle which is deprecated, I upgraded to v7 and it works now – waterlooalex May 30 '15 at 18:33
5

For those encountering the same problem as Dapp (toggle showing back arrow instead of hamburger icon), this is most likely because you're missing a drawerToggle.syncState() in your Activity.

To be more specific, you have to override the onPostCreate() method like this :

@Override
protected void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    drawerToggle.syncState();
}

This isn't the only method that needs to be overriden. See this post by jpardogo for more details.

Community
  • 1
  • 1
Ronan
  • 398
  • 3
  • 12
0

also be sure to use the right theme on your actionbar...if your actionbar is dark, the default icon might be black unless you do this: "@style/ThemeOverlay.AppCompat.Dark.ActionBar"

It bit me, but only on Android 4.x devices (5.x+ worked fine oddly enough)

kenyee
  • 2,309
  • 1
  • 24
  • 32