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.