在菜单图标不显示在安卓 [英] icon in menu not showing in android
本文介绍了在菜单图标不显示在安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想菜单处理程序添加到我的项目,我读<一href="http://developer.android.com/guide/topics/ui/menus.html">http://developer.android.com/guide/topics/ui/menus.html同样,它很简单,但图标不会显示给我,我很困惑。即使我以编程方式添加菜单项。 我的code是:
@覆盖
公共布尔onCreateOptionsMenu(功能菜单){
menu.add(0,0,0,退出)的setIcon(R.drawable.ic_launcher)。
。getMenuInflater()膨胀(R.layout.menu,菜单);
返回true;
}
和XML:
&LT; XML版本=1.0编码=UTF-8&GT?;
&LT;菜单的xmlns:机器人=http://schemas.android.com/apk/res/android&GT;
&LT;! - 单个菜单项
集ID,图标和标题每个菜单项
- &GT;
&LT;项目机器人:ID =@ + ID / menu_bookmark
机器人:图标=@可绘制/更新
机器人:标题=@字符串/更新/&GT;
&LT; /菜单&gt;
解决方案
如果你在Android 3.0+上运行您的code,在菜单中的图标设计不显示。这是由谷歌设计决策。
您可以阅读更多关于它在这个的上Android开发者博客。
i want to add menu handler to my project, i read http://developer.android.com/guide/topics/ui/menus.html too,its very simple but icon not shown to me, i very confused. even i add menu item programmatically. my code is:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, 0, 0, "Quit").setIcon(R.drawable.ic_launcher);
getMenuInflater().inflate(R.layout.menu, menu);
return true;
}
and in xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Single menu item
Set id, icon and Title for each menu item
-->
<item android:id="@+id/menu_bookmark"
android:icon="@drawable/update"
android:title="@string/Update" />
</menu>
解决方案
If you're running your code on Android 3.0+, the icons in the menu are not shown by design. This is a design decision by Google.
You can read more about it in this on Android developers blog.
这篇关于在菜单图标不显示在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文