1

I use ActionBarSherlok and DrawerLayout, all works fine, but in Android 2.3 ActionBar drawer icon not displays. Insted it displays back icon. In Android 4 displays drawer icon.

enter image description here

How can I change back icon in Android 2 to drawer icon like in Android 4?

I use next code to initialize drawer:

drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

drawerToggle = new ActionBarDrawerToggle(this, drawer,
        R.drawable.ic_drawer, R.string.main_01, R.string.main_02) {
    public void onDrawerClosed(View view) {
        getSupportActionBar().setTitle(title);
        invalidateOptionsMenu();
    }

    public void onDrawerOpened(View drawerView) {
        getSupportActionBar().setTitle(drawerTitle);
        invalidateOptionsMenu();
    }
};

drawer.setDrawerListener(drawerToggle);     
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Nik
  • 7,114
  • 8
  • 51
  • 75
  • Check out similar post http://stackoverflow.com/questions/9252354/how-to-customize-the-back-button-on-actionbar – GrIsHu Oct 01 '13 at 13:08

2 Answers2

1

The "up" affordance indicator is provided by a drawable specified in the homeAsUpIndicator attribute of the theme. To override it with your own custom version it would be something like this:

<style name="Theme.MyFancyTheme" parent="android:Theme.Holo">
   <item name="android:homeAsUpIndicator">@drawable/my_fancy_up_indicator</item>
  </style>

If you are supporting pre-3.0 with your application be sure you put this version of the custom theme in values-v11 or similar.

GrIsHu
  • 29,068
  • 10
  • 64
  • 102
0

ActionBarDrawerToggle is for the native API Level 11 action bar, and perhaps for the AppCompat action bar (not sure about that one).

For ActionBarSherlock, either use a Sherlock-aware drawer implementation, or implement workarounds as described in this issue and this issue.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491