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

Clear the app data programmatically in android

convert an integer to a string in java

Print the large string values in android log cat.