无图标显示在Android的选项菜单项 [英] No icon showing in Android Options menu item

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

问题描述

我已经创建了一个选项菜单,图标我自己(24PX x 24PX),但它没有显示。

I have created an options menu with an icon I made myself (24px x 24px) but it is not showing.

在code。在我的XML(位于RES /菜单)如下:

The code in my xml (located in res/menu) is the following:

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/menu_insert"
    android:icon="@drawable/menu_add"
    android:title="@string/menu_insert" />
</menu> 

菜单是在我的Activity.java文件,如文档中说,创建的:

The menu is created in my Activity.java file as said in the documentation:

public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);
    MenuInflater mi = getMenuInflater();
    mi.inflate(R.menu.list_menu, menu);
return true;
}

PS项的标题位于一路向左,我似乎无法找到的文档中的任意位置如何居中(显然安卓比重,没有在那里进行)

PS The item's title is located all the way to the left and I can't seem to find anywhere in the documentation how to center it (apparently android:gravity is not done there)

感谢

推荐答案

我觉得您的来电 super.onCreateOptionsMenu(菜单)应删除,这是没有必要的,似乎改变你的菜单。

I think your call to super.onCreateOptionsMenu(menu) should be deleted, it's not necessary and seems to alter your menu.

这篇关于无图标显示在Android的选项菜单项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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