Android的选项菜单图标不显示 [英] Android options menu icon won't display

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

问题描述

我下面一本关于Android的发展让自己开始写我的第一个真正的应用程序。 我起身,我正在做一个选项菜单为我的活动之一的地步。菜单显示出来,但菜单项对应的图标,拒绝显示。 这里是$ C $下菜单:

I'm following a book on Android Development to get myself started writing my first real app. I got up to the point where I'm making an options menu for one of my activities. The menu shows up, but the corresponding icon of the menu item refuses to display. Here is the code for the menu:

ReminderListActivity

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

RES /菜单/ list_menu.xml

<?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>

我已经从我的Andr​​oid SDK的一个子文件夹中复制的ic_menu_add.png图标(32x32px)我RES /绘制-MDPI文件夹,重命名为menu_add.png文件。我刷新文件夹中的日食所以图标显示,并且你可以看到我将它作为我的布局文件菜单项的图标。我尝试运行我的项目在模拟器几次,但是图标一直没有出现。为了记录在案,我使用的是Android 4.0.3 ..

I have copied the ic_menu_add.png icon (32x32px) from one of my Android SDK subfolders to my res/drawable-mdpi folder and renamed the file to menu_add.png. I refreshed the folder within eclipse so the icon shows up, and as you can see I set it as the icon for the menu item in my layout file. I tried running my project in the emulator a few times, but the icon never shows up. For the record, I am using Android 4.0.3..

任何想法?

推荐答案

在安卓3.0+,对于选项菜单中的preferred方式(操作栏中外溢菜单)将不显示图标。如果你有安卓targetSdkVersion =11或更高,图标将不会出现在菜单上的Andr​​oid 3.0+。该图标将显示,如果你推广一个选项菜单项是一个工具栏按钮,图标将出现在Android 1.x的/ 2.x设备。

On Android 3.0+, the preferred approach for the options menu (a spillover menu in the action bar) will not show icons. If you have android:targetSdkVersion="11" or higher, icons will never show up in menus on Android 3.0+. The icons will show up if you promote an options menu item to be a toolbar button, and the icons will show up on Android 1.x/2.x devices.

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

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