Back Button Is Not Working Properly In Right Side Of Action Bar
Solution 2:
First of all i wanted to say what you are trying to do is not a good practice, why would you want a back button in your action bar if Android devices already have one on the bottom of the screen and you can turn on Up-Navigation at the left side of the Action Bar?
Custom App-Navigation clutters your code, confuses users and most of the time is just ugly.
But if you really need a button that does the navigation, you want it to access the standard android navigation methods.
For Back Navigation:
Just use the standard android back action onBackPressed().
publicbooleanonOptionsItemSelected(MenuItem item) {
if (mDrawerToggle.onOptionsItemSelected(item)) {
returntrue;
}
switch (item.getItemId()) {
case R.id.backAction:
onBackPressed();
returntrue;
default:
returnsuper.onOptionsItemSelected(item);
}
}
If this function doesn't do what you want, you can just override it with your own wanted behavior.
For Up Navigation:
publicbooleanonOptionsItemSelected(MenuItem item) {
if (mDrawerToggle.onOptionsItemSelected(item)) {
returntrue;
}
switch (item.getItemId()) {
case R.id.backAction:
NavUtils.navigateUpFromSameTask(this);
returntrue;
default:
returnsuper.onOptionsItemSelected(item);
}
}
You will have to configure your parent activites in the manifest, but because of that the behavior of this Navigation is easier to change.
Post a Comment for "Back Button Is Not Working Properly In Right Side Of Action Bar"