Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save EduardoSP6/89021424e73e2ab1b2f5fd80411a708b to your computer and use it in GitHub Desktop.
Save EduardoSP6/89021424e73e2ab1b2f5fd80411a708b to your computer and use it in GitHub Desktop.
Show arrow back button in Activity Toolbar (Android)
PS.: It will not work on MainActivity.
@Override
protected void onCreate(Bundle savedInstanceState) {
...
// insert this two lines
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}
// override this method
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == android.R.id.home) {
finish();
}
return super.onOptionsItemSelected(item);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment