Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation Drawer icon not showing (Sherlock actionbar)

Tags:

android

Have the navigation Drawer working with the sherlock actionbar but i am having trouble getting the 3 line icon (like gmail) to show instead of the normal up button "<". Here is my code ic_drawer is the 3 line icon that gmail uses

getSupportActionBar().setIcon(R.drawable.myIcon);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawer,
            R.drawable.ic_drawer, R.string.menu_open, R.string.menu_close) {
        public void onDrawerClosed(View view) {

            super.onDrawerClosed(view);
        }

        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
        }
    };
like image 559
user1634451 Avatar asked Jun 10 '13 18:06

user1634451


2 Answers

Have you tried implementing the method:

    mDrawerToggle.syncState();

This has worked for me in the past.

like image 172
wazim Avatar answered Sep 18 '22 13:09

wazim


This solution worked for me, and showed default navigation drawer icon in all version. Add SherlockNavigationDrawer library from here https://github.com/nicolasjafelle/SherlockNavigationDrawer to your project. And change your code as below :

SherlockActionBarDrawerToggle mDrawerToggle = new SherlockActionBarDrawerToggle(this,mDrawerLayout,
   R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
   public void onDrawerClosed(View view) {
       super.onDrawerClosed(view);
   }
   public void onDrawerOpened(View drawerView) {
       super.onDrawerOpened(drawerView);
   }
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
getSupportActionBar().setIcon(R.drawable.ic_launcher);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
like image 45
Dory Avatar answered Sep 21 '22 13:09

Dory