[英]OptionMenu does not show anything
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// mEditor=(TextView)findViewById(R.id.text);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
Log.d("sayem", "onCreateOptionMEnu");
return true;
}
And this is my menu.xml file path res/menu/menu.xml 这是我的menu.xml文件路径res / menu / menu.xml
<item
android:id="@+id/settings"
android:alphabeticShortcut="@string/settings_shortcut"
android:icon="@drawable/violet"
android:title="@string/settings_label"
android:visible="true"/>
It does not show any kind of menu as expected. 它没有显示任何菜单如预期的那样。
If you look at the example here , the menu.xml file (or game_menu.xml file) has an outer tag called <menu>
. 如果在此处查看示例,则menu.xml文件(或game_menu.xml文件)具有名为<menu>
的外部标记。 I don't see that in yours. 我看不到你的。
Example: 例:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:icon="@drawable/ic_new_game"
android:title="@string/new_game" />
<item android:id="@+id/help"
android:icon="@drawable/ic_help"
android:title="@string/help" />
</menu>
Either you have not posted your full menu.xml, or it isn't formed as it should be. 您可能尚未发布完整的menu.xml,或者未按预期形成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.