ActionBarDrawerToggle is not setting Drawer Indicator

可紊 提交于 2019-12-02 23:09:35

You'll have to use

getActionBar().setDisplayShowHomeEnabled(true);

instead of

getActionBar().setDisplayShowHomeEnabled(false);

Cheers,

Felix

EDIT: Here's how to hide the Icon via XML:

add this to your styles.xml: (Replace android:Widget.Holo.Light.ActionBar.Solid with android:Widget.Holo.ActionBar.Solid if you are using the dark action bar)

<style name="ActionBarStyle" parent="android:Widget.Holo.Light.ActionBar.Solid">
    <item name="android:icon">@android:color/transparent</item>
</style>

and then add this to your Theme you have defined in AndroidManifest.xml (Standard is the AppBaseTheme in /res/values-v11/styles.xml - AppBaseTheme:

<item name="android:actionBarStyle">@style/ActionBarStyle</item>

Hope this helps!

try this code

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

This worked for me when I wanted to get the menu icon back from the back arrow

private void updateNavigationIcon() {
    if (getSupportFragmentManager().getBackStackEntryCount() == 0
            && getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(false);
        toggle.syncState();
    }
}

Just add the following line inside showGlobalContextActionBar() method (NavigationDrawerFragment.java class)

actionBar.setHomeAsUpIndicator(R.drawable.ic_action_menu);

Code snippet:

private void showGlobalContextActionBar() {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setHomeAsUpIndicator(R.drawable.ic_action_menu);
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
        actionBar.setTitle(R.string.app_name);
    }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!