动作条/菜单的默认图标 [英] ActionBar/Menu default icons

查看:232
本文介绍了动作条/菜单的默认图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个菜单,其中包含有自带的SDK(从SKD /平台/ ...)图标的项目。在ICS它显示的罚款(暗行动起来吧,光色图标),但在Android 2.2系统,你无法看到图标,因为默认的主题是白色的,所以是图标。
是否有访问Android的默认图标,使用搜索栏时喜欢的方式,正确地显示在所有Android版本的图标?是否有访问Android的默认图标的方式?

I have a menu, which contain an item with an icon that comes with sdk (from skd/platform/...). In ICS it's displayed fine (dark action bar, light color icon), but in android 2.2, you can't see the icon because the default theme is white and so is the icon. Is there a way to access android default icons, like when using the search bar, the icon is displayed correctly on all android versions? Is there a way to access android default icons?

推荐答案

如果你是在一个XML定义你的菜单,然后像这样将确保图标始终从相应的SDK可绘制回升。

If you are defining your menu in an XML, then something like this will ensure the icons are always picked up from the corresponding SDK drawables.

<item
    android:id="@+id/menuID"
    android:icon="@android:drawable/ic_menu_add"
    android:showAsAction="always"
    android:title="Some Label">
</item>

如果您在您的Java code加入你的菜单项,这样的事情应该这样做:

If you are adding your Menu Items in your Java code, something like this should do it:

menu.add(1, 1, 1, "Some Label").setIcon(android.R.drawable.ic_menu_add);

请注意:你应该检查,如果你打算使用的图标是常见的跨所有平台,以确保一个统一的,无错功能为您的用户

Note: You should check if the icons you intend to use are common across all platforms to ensure a uniform and error free functioning for your users.

这篇关于动作条/菜单的默认图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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