可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
What is the difference between actionBar back button and android back button? Because it's seems that the ActionBar back button which is called with:
ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true);
it works way better...
example: when I press the ActionBar back button the animations are there, but if I press the default back button they aren't.
I can change theme from a preference activity: If I go back with the ActionBar back button the colors instantly changed, but with the default I have to restart the app....
how can I make my default back button to behave like the ActionBar one?
回答1:
The ActionBar "back" button is actually an "Up" button and it should take you to higher level on your app's navigation hierarchy. The back button takes you to the last place you were looking at.
Another great tip to better undertand this is that the "Up" button should always take you to a place on your app, while the back button might take you to another app.
You might want to read this article to better understand the difference: http://developer.android.com/design/patterns/navigation.html
回答2:
The android back button navigates "back". The nav bar button navigates "up". Up navigation always leads you to the same app you were on, just a different activity. Back can change app AND activity.
回答3:
By an example:
Go to the Gmail app, start to reply to an email by typing the message, don't send. just now:
- if back button pressed → only the keyboard will be closed.
- if Up button pressed ---→ both keyboard and reply activity will be closed.
not related with specific app.
related with specific app.
回答4:
In Activity B:
@Override public void onBackPressed() { NavUtils.navigateUpFromSameTask(this); super.onBackPressed(); }
The parent activity must be specified in the manifest file. See also https://developer.android.com/training/implementing-navigation/ancestral.html