Afkar
Afkar

Reputation: 3

action bar icon keep showing back icon

i'm literally new in developing android apps. My project using navigation drawer between fragments. i tried to custom the drawer with tutorial http://www.tutecentral.com/android-custom-navigation-drawer/ and got an error. in my application, in action bar, it keeps showing back icon instead the default icon.

this is url for before-after image of actionbar : http://oi58.tinypic.com/2ahsbys.jpg

here is the code i'm confused of (pretty same with the tutorial, tell me if there's something i missed)

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    getSupportActionBar().setHomeButtonEnabled(true);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
            R.drawable.ic_drawer, R.string.navigation_drawer_open,
            R.string.navigation_drawer_close) {
        public void onDrawerClosed(View view) {
            getSupportActionBar().setTitle(mTitle);
            invalidateOptionsMenu(); // creates call to
            // onPrepareOptionsMenu()
        }

        public void onDrawerOpened(View drawerView) {
            getSupportActionBar().setTitle(mDrawerTitle);
            invalidateOptionsMenu(); // creates call to
            // onPrepareOptionsMenu()
        }
    };

if i delete setDisplayHomeAsUpEnabled, the back icon is gone but i can't click somewhere to display the drawer, i have to slide it. please refer me if someone has solved it. many thanks.

*i have changed the R.drawable.ic_drawer to other drawable icons but it had no effects.

Upvotes: 0

Views: 293

Answers (1)

random
random

Reputation: 10309

Try setting a theme for your activity in manifest file and inside styles.xml set your drawable for homeAsUpIndicator for that theme

<style name="CustomTheme" parent="@style/Widget.AppCompat.ActionBar"> 
     <item name="homeAsUpIndicator">@drawable/ic_drawer</item> 
</style>

Upvotes: 1

Related Questions