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

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

问题描述

您好球员我真的很沮丧,这是​​我想要得到

但我什么都这样,我不能让我的图标键合到我的选项菜单。我试图

  @覆盖
公共布尔onCreateOptionsMenu(菜单菜单)
{
    menu.add(1,1,0,蓝光)的setIcon(R.drawable.ic_launcher)。
     menu.add(1,2,1,DVD)的setIcon(R.drawable.ic_launcher)。
     menu.add(1,3,2,硬盘)的setIcon(R.drawable.ic_launcher)。
     menu.add(1,4,3,网站)的setIcon(R.drawable.ic_launcher)。
     menu.add(1,5,4,USB)的setIcon(R.drawable.ic_launcher)。
 返回true;
}
 

但没有运气

然后我试着去我的菜单,然后main.xml中,做

 <菜单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>

<项目
    机器人:ID =@ + ID / action_settings
    机器人:图标=@可绘制/ ic_launcher
    机器人:showAsAction =从不
    机器人:标题=棒棒/>
 

和在我的课我没有

  @覆盖
公共布尔onCreateOptionsMenu(功能菜单){
    //充气菜单;这增加了项目操作栏,如果它是present。
    。getMenuInflater()膨胀(R.menu.main,菜单);
    返回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天全站免登陆