0

我如何使活动中的图标显示为带箭头的后退按钮?我已经搜索但没有找到任何答案。

非常感谢

4

3 回答 3

3

它在ActionBar API - setDisplayHomeAsUpEnabled(boolean)中。

getActionBar().setDisplayHomeAsUpEnabled(true);
于 2013-03-08T18:04:29.700 回答
1

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);
    ...
}
于 2013-03-08T18:04:45.890 回答
0

如果您使用的是 Action Bar Sherlock,请使用此代码:getSupportActionBar().setDisplayHomeAsUpEnabled(true);
否则您可以使用getActionBar().setDisplayHomeAsUpEnabled(true);

于 2013-03-08T18:26:42.867 回答