The Android ActionBar home navigation related methods

  • setHomeButtonEnabled(boolean)
  • setDisplayHomeAsUpEnabled(boolean)
  • setDisplayShowHomeEnabled(boolean)

 

setHomeButtonEnabled(boolean )

It will just make the icon clickable, with the color at the background of the icon as a feedback of the click. This method is similar to the next one actually, except that the left-facing caret doesn’t show up unless the android:parentActivityName is specified. Both setDisplayHomeAsUpEnabled() and setHomeButtonEnabled() calls onOptionsItemSelected() on the Activity where you can check the item.getItemId() against android.R.id.home and perform some action.

 

setDisplayHomeAsUpEnabled(boolean)

actionBar.setDisplayHomeAsUpEnabled(true) will make the icon clickable and add the < at the left of the icon. This method action bar clickable so that “up” (ancestral) navigation can be provided, but not actually add the functionality of navigating upwards. That has to be done by specifying the android:parentActivityName (takes the parent activity class name) on the activity in the manifest file.

 

setDisplayShowHomeEnabled(boolean)

It specifies whether or not the Home button is shown. It is used in conjunction with setDisplayHomeAsUpEnabled().

 

Reference