我想添加ActionBar按鈕到FragmentActivity,我無法弄清楚我做錯了什麼。 當運行應用程序的所有我看到的是在動作條,而不是我的按鈕的默認菜單按鈕..FragmentActivity Action Bar選項菜單
的FragmentActivity:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.animalsmenu,menu);
return true;
}
的xml文件:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/dogs"
android:title="Dogs"
android:orderInCategory="1"
app:showAsAction="always">
</item>
看看我的答案在這裏:http://stackoverflow.com/questions/25700575/acessing-the-options-menu-from-a-fragment-android/25700901#25700901 – XDnl 2014-09-06 20:20:56
@XDnl:這個問題(根據到OP)顯示來自'FragmentActivity',而不是'Fragment'的代碼。 – Squonk 2014-09-06 20:26:51