Browsed by
Tag: android toolbar back button

Android navigation/ toolbar back

Android navigation/ toolbar back

Step one : put these in oncreate method getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true);     @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_details); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowHomeEnabled(true); } Step two : Give action to go specific page or actions @Override public boolean onOptionsItemSelected(MenuItem item) { Intent intent = new Intent(fromActivity.this, toActivity.class); startActivity(intent); return super.onOptionsItemSelected(item); } @Override public void onBackPressed() { super.onBackPressed(); Intent intent = new Intent(fromActivity.this, toActivity.class); startActivity(intent); }