Android 菜单项标题未显示 [英] Android Menu Item Title not displaying

查看:22
本文介绍了Android 菜单项标题未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在摆弄 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆