我已經設置了我的操作欄,但是當我單擊主頁向上按鈕時沒有任何反應。 下面兩個選項是啓用的,所以不應該自動進入家庭活動?Android操作欄主頁按鈕
ab.setHomeButtonEnabled(true);
ab.setDisplayHomeAsUpEnabled(true);
操作欄
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
final String[] activities;
Resources res = getResources();
activities = res.getStringArray(R.array.activities);
ActionBar ab = getActionBar();
ab.setHomeButtonEnabled(true);
ab.setDisplayHomeAsUpEnabled(true);
ab.setTitle(R.string.app_name);
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
ab.show();
/** Create an array adapter to populate dropdownlist */
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_dropdown_item, activities);
/** Setting dropdown items and item navigation listener for the actionbar */
getActionBar().setListNavigationCallbacks(adapter, navigationListener);
/** Enabling dropdown list navigation for the action bar */
getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
return true;
}
檢查此鏈接中的代碼會有幫助。 [鏈接代碼](http://stackoverflow.com/questions/11304483/proper-way-to-handle-action-bar-button/37692750#37692750) – 2016-06-08 03:49:37