0

I am implementing an action bar with ActionBarSherlock with an ActionBarDrawerToggle. It is supposed to display an hamburger button on the left side of the action bar. It is working well on higher api level (Tested on devices above api level 16). However it doesn't work on an Android 2.3.7 device (api 10). On this device, a left caret (<) is displayed. I searched the internet but seems this is not a common issue. So I am sure if I am doing something wrong:

Here is how I handle the ActionBarDrawerToggle in my code:

public class MyActivity extends SherlockFragmentActivity {
    private ActionBarDrawerToggle drawerToggle;
    private MySidebarDrawerLayout sidebarDrawerLayout;
    ...

@Override
protected final void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.home);
    // init side bar drawer
    sidebarDrawerLayout = (SidebarDrawerLayout) 
        findViewById(R.id.sidebar_drawer_layout);

    drawerToggle = new ActionBarDrawerToggle(this, sidebarDrawerLayout, R.drawable.hamburger, R.string.drawer_open,R.string.drawer_close) {
        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }

        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
        }
    };

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    ...
}
}

So why the hamburger is not showing on lower api?

darklord
  • 5,077
  • 12
  • 40
  • 65

1 Answers1

2

Declare in your Style

<style name="AppBaseTheme" parent="@style/Theme.Sherlock.Light">

      <item name="homeAsUpIndicator">@drawable/hamburger</item>

</style>

and mention in your Manifest

 android:theme="@style/AppBaseTheme"
Mubarak Mohideen
  • 404
  • 5
  • 14
  • Thanks! This is working. But the new problem is the hamburger doesn't change back to left caret when I open the search box on action bar. How can I set it back programmatically? – darklord Jul 15 '14 at 20:13