I want to enable the home button in the Action bar. I'm using this code:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
actionbar.setHomeButtonEnabled(true);
actionbar.setDisplayHomeAsUpEnabled(true);
}
In this I'm using setHomeButtonEnabled
and setDisplayHomeAsUpEnabled
to put a back mark at icon in ActionBar. If I use only setDisplayHomeAsUpEnabled
then also will it work? Is there a need to set setHomeButtonEnabled
to true?
What is the difference between the two?
For what you want to do, actionBar.setDisplayHomeAsUpEnabled(true)
is enough.
For the difference :
actionBar.setHomeButtonEnabled(true)
will just make the icon clickable, with the color at the background of the icon as a feedback of the click.
actionBar.setDisplayHomeAsUpEnabled(true)
will make the icon clickable and add the <
at the left of the icon.
As Android says:
- setDisplayShowHomeEnabled(boolean showHome)
// Set whether to include the application home affordance in the action bar.
// (and put a back mark at icon in ActionBar for "up" navigation)
-setHomeButtonEnabled(boolean enabled)
// Enable or disable the "home" button in the corner of the action bar.
// (clickable or not)
It should be quite clear i think