Zhangali Bidaibekov
Zhangali Bidaibekov

Reputation: 701

ActionBar icon is not showing if setDisplayHomeEnabled is false

I want to set icon on ActionBar. So when I have setDisplayShowHomeEnabled set to true icon shows, when false - nothing. I don't want show back button on actionBar, only icon. What's the problem?

            actionBar.setTitle("");
            actionBar.setDisplayShowCustomEnabled(true);
            actionBar.setDisplayShowHomeEnabled(true);
            actionBar.setDisplayShowTitleEnabled(true);
            actionBar.setIcon(getResources().getDrawable(R.drawable.logo_big));

Upvotes: 0

Views: 169

Answers (1)

Sagar Chavada
Sagar Chavada

Reputation: 5269

For Back button write this code:

actionbar.setDisplayShowHomeEnabled(true);
actionbar.setDisplayHomeAsUpEnabled(false);

It's by default false though, but in your case if it's showing, then you have to set it to false programatically.

You have to use getSupportActionBar() instead of getActionBar().

Upvotes: 1

Related Questions