我如何使活动中的图标显示为带箭头的后退按钮?我已经搜索但没有找到任何答案。
非常感谢
它在ActionBar API - setDisplayHomeAsUpEnabled(boolean)中。
getActionBar().setDisplayHomeAsUpEnabled(true);
Per the Pure Android design guidelines:
Don't use labeled back buttons on action bars Other platforms use an explicit back button with label to allow the user to navigate up the application's hierarchy. Instead, Android uses the main action bar's app icon for hierarchical navigation and the navigation bar's back button for temporal navigation. For more information, please review the Navigation pattern.
Follow this guideline to provide a consistent navigation experience across the platform.
However, you can use the 'Up' button on Android 3.0+ devices (or using ActionBarSherlock, any Android 2.2+ device) per training on implementing Ancestral Navigation
@Override
public void onCreate(Bundle savedInstanceState) {
...
getActionBar().setDisplayHomeAsUpEnabled(true);
...
}
如果您使用的是 Action Bar Sherlock,请使用此代码:getSupportActionBar().setDisplayHomeAsUpEnabled(true);
否则您可以使用getActionBar().setDisplayHomeAsUpEnabled(true);