Search code examples
androidandroid-actionbar

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));

Solution

  • 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().