Skip to content Skip to sidebar Skip to footer

Navigation Drawer Doesn't Show Icon In Actionbar

I have added navigation drawer to an activity which contains PagerSlidingStrip.I can see the navigation drawer when I slide from left to right of screen but I can't see navigation

Solution 1:

add this

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    return super.onOptionsItemSelected(item);
}

Solution 2:

try this for visible your menu icon.

        actionBar = getActionBar();
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayUseLogoEnabled(false);
        actionBar.setHomeButtonEnabled(true);
        actionBar.setIcon(R.drawable.menu);

and override onOptionsItemSelected like below for open drawer

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        //Open your drawer here
        break;
    }
    return super.onOptionsItemSelected(item);
}

Solution 3:

Use

         ActionBar actionBar = getSupportActionBar();
        actionBar .setDisplayHomeAsUpEnabled(true);
        actionbar.setDisplayShowHomeEnabled(true);
           actionBar.setHomeButtonEnabled(true); 

or

and use

getActionBar().setDisplayHomeAsUpEnabled(true); // also required
    if (Build.VERSION.SDK_INT >= 18) {
        getActionBar().setHomeAsUpIndicator(
            getResources().getDrawable(R.drawable.ic_navigation_drawer));
    }

Solution 4:

Add the below code

/**
     * When using the ActionBarDrawerToggle, you must call it during
     * onPostCreate() and onConfigurationChanged()...
     */

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred.
        mDrawerToggle.syncState();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        // Pass any configuration change to the drawer toggls
        mDrawerToggle.onConfigurationChanged(newConfig);
    }

Solution 5:

Use this

    getSupportActionBar().setDisplayUseLogoEnabled(true);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setLogo(R.drawable.ic_launcher);
    getSupportActionBar().setDisplayShowHomeEnabled(true);

this may help you


Post a Comment for "Navigation Drawer Doesn't Show Icon In Actionbar"