在选项菜单中无法显示图标 [英] Cannot Display Icon In The Options Menu

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

问题描述

你好,我真的很沮丧,这是我想要得到的。





但是我做了什么,我无法将我的图标绑定到我的选项菜单。我试过

  @Override 
public boolean onCreateOptionsMenu(菜单菜单)
{
菜单.add(1,1,0,Blu-Ray)。setIcon(R.drawable.ic_launcher);
menu.add(1,2,1,DVD)。setIcon(R.drawable.ic_launcher);
menu.add(1,3,2,Hard Disk)。setIcon(R.drawable.ic_launcher);
menu.add(1,4,3,Sites)。setIcon(R.drawable.ic_launcher);
menu.add(1,5,4,USB)。setIcon(R.drawable.ic_launcher);
返回true;
}

但没有运气



然后我尝试去main.xml中的菜单,并且执行

 < menu xmlns:android =http ://schemas.android.com/apk/res/android> 

< item
android:id =@ + id / action_settings
android:icon =@ drawable / ic_launcher
android:showAsAction =never
android:title =Lolly/>



  @Override 
public boolean onCreateOptionsMenu(菜单菜单){
//扩充菜单;如果存在,则会将项目添加到操作栏。
getMenuInflater()。inflate(R.menu.main,menu);
返回true;
}


解决方案


在选项菜单中无法显示图标


请注意,Android 3.0没有更多的选项菜单。有动作栏溢出。 选项菜单仍然用于某些方法名称(例如, onCreateOptionsMenu())用于向后兼容性,但选项菜单本身是Android 1.x / 2 .x构造。


你好,我真的很沮丧这就是我想要得到的




这不是一个选项菜单,也不是动作栏溢出。这个应用程序的开发人员是一些独立创建的UI。


但是我做了什么我无法将我的图标绑定到我的选项菜单


动作栏溢出没有图标。旧的选项菜单有图标,但是与截图中描绘的图形不同。


我想实现上述布局


欢迎您自己创建一些UI。或者,您可以坚持使用标准操作栏/选项菜单方法,以便您的应用程序与用户设备上的其他应用程序一致。


Hello guys I am really frustrated this is what I want to get

but I what ever I do I cannot get my icon bonded to my Options Menu. I have tried

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    menu.add(1, 1, 0, "Blu-Ray").setIcon(R.drawable.ic_launcher);
     menu.add(1, 2, 1, "DVD").setIcon(R.drawable.ic_launcher);
     menu.add(1, 3, 2, "Hard Disk").setIcon(R.drawable.ic_launcher);
     menu.add(1, 4, 3, "Sites").setIcon(R.drawable.ic_launcher);
     menu.add(1, 5, 4, "USB").setIcon(R.drawable.ic_launcher);
 return true;
}

but with no luck

I then tried to go to my menu then main.xml and did

<menu xmlns:android="http://schemas.android.com/apk/res/android" >

<item
    android:id="@+id/action_settings"
    android:icon="@drawable/ic_launcher"
    android:showAsAction="never"
    android:title="Lolly"/>

And in my Class I did

    @Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

解决方案

Cannot Display Icon In The Options Menu

Note that there is no more "options menu" as of Android 3.0. There is the action bar overflow. "Options menu" is still used in some method names (e.g., onCreateOptionsMenu()) for backwards compatibility, but the "options menu" itself is an Android 1.x/2.x construct.

Hello guys I am really frustrated this is what I want to get

That is not an options menu, nor the action bar overflow. It is some UI that the developer of that app created independently.

but I what ever I do I cannot get my icon bonded to my Options Menu

The action bar overflow does not have icons. The old options menu had icons, but with a different rendering than is depicted in your screenshot.

I would like to achieve the layout as above

You are welcome to create some UI for this yourself. Or, you can stick to the standard action bar/options menu approach, so that your application will behave consistently with the other applications on the users' devices.

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

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