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);
}
}


Comments

Popular posts from this blog

Flutter Bloc - Clean Architecture

Dependencies vs Dev Dependencies in Flutter

What's new in android 14?