Skip to content

Instantly share code, notes, and snippets.

@shihabmi7
Created June 23, 2016 04:45
Show Gist options
  • Save shihabmi7/aeed64d9c1405f99985e93ad65280f91 to your computer and use it in GitHub Desktop.
Save shihabmi7/aeed64d9c1405f99985e93ad65280f91 to your computer and use it in GitHub Desktop.
Action Bar Heads Up Display: Check Home Page & Set Back Button
ActionBar mActionBar = getSupportActionBar();
// checking either this is home actiivty or not for
// ActionBar.DISPLAY_HOME_AS_UP
if (this.getClass().getSimpleName()
.equalsIgnoreCase(RestaurentListActivity.class.getSimpleName())) {
mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE
| ActionBar.DISPLAY_SHOW_CUSTOM
| ActionBar.DISPLAY_SHOW_HOME);
} else {
mActionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP
| ActionBar.DISPLAY_SHOW_TITLE
| ActionBar.DISPLAY_SHOW_CUSTOM
| ActionBar.DISPLAY_SHOW_HOME);
}
@shihabmi7
Copy link
Author

shihabmi7 commented Sep 15, 2016

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

ActionBar mActionBar = getSupportActionBar();
mActionBar.setDisplayHomeAsUpEnabled(true);

*

*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment