我想添加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