Back Navigation in action bar
Sometimes most of developers now using ActionBar. They need to navigate button on top, if they need just add few lines in the code.
getActionBar().setDisplayHomeAsUpEnabled(true);
and
public boolean onOptionsItemSelected(MenuItem item) {
// Take appropriate action for each action item click
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
getActionBar().setDisplayHomeAsUpEnabled(true);
and
public boolean onOptionsItemSelected(MenuItem item) {
// Take appropriate action for each action item click
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Comments