Android菜单项标题未显示 [英] Android Menu Item Title not displaying
问题描述
我一直在摆弄android,并且一直在关注菜单示例,它运行得很好,但是菜单项的标题"字段未显示.
I've been fiddling with android, and I've been following the menu sample, and it runs almost fine, but the "title" field of the menu items isn't displaying.
我认为这与以下问题有关: https://stackoverflow.com/questions/3286093/android-menu-item-not-显示文字 但我不确定他的回答是什么意思.
I think it's related to this question: https://stackoverflow.com/questions/3286093/android-menu-item-not-showing-text but I'm not sure what his answer means.
无论如何,可以正确地得到我有2个菜单项,只是不显示文本.我不太确定错误在哪里,所以想多看一下眼睛会很好.
Anyway, it properly gets that I have 2 menu items, it just isn't displaying the text. I'm not quite sure where the error is and figured extra sets of eyes would be good.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="https://schemas.android.com/apk/res/android">
<item android:id="@+id/options"
android:title="@string/main_options" />
<item android:id="@+id/options2"
android:title="@string/main_options2" />
</menu>
充气机:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_menu, menu);
return true;
}
如果还有其他需要,请告诉我.
If anything else is needed, let me know.
字符串文件:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World!</string>
<string name="app_name">LifeInColor</string>
<string name="main_options">Options</string>
<string name="main_options2">Something goes here</string>
</resources>
将xml更改为:
<?xml version="1.0" encoding="UTF-8"?>
<menu xmlns:android="https://schemas.android.com/apk/res/android">
<item android:id="@+id/options"
android:title="@string/main_options" />
<item android:id="@+id/options2"
android:title="Something goes here" />
</menu>
获得相同的结果.我有一张照片,但是因为我是新来的,所以它不允许我发布.
gets the same result. I have a picture, but it won't let me post it because I'm new.
推荐答案
在菜单文件中,将https://schemas.android.com/apk/res/android
替换为http://schemas.android.com/apk/res/android
( https -> http ).因此,看来该错误是由于不正确的架构地址造成的.
In your menu file replace https://schemas.android.com/apk/res/android
with http://schemas.android.com/apk/res/android
(https -> http). So it looks like the error was due to incorrect schema address.
这篇关于Android菜单项标题未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!