gpt4 book ai didi

android - 添加带有子菜单项的图标

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:51:18 34 4
gpt4 key购买 nike

我制作了包含一些项目的子菜单。现在我想用子菜单项添加不同的图标。我还将代码应用于添加图标的菜单项,但它没有显示图标我的代码是这样的:

public boolean onCreateOptionsMEnu(Menu m) {
SubMenu s1 = m.addSubMenu("menu1");
s1.add(0,0,1,"1").setIcon(R.drawable.icon1);
s1.add(0,1,2,"2").setIcon(R.drawable.icon2);

return super.onCreateOptionsMenu(m);
}

最佳答案

子菜单不支持图标。

https://developer.android.com/guide/topics/ui/menus.html :

Icon Menu
This is the collection of items initially visible at the bottom of the screen at the press of the MENU key. It supports a maximum of six menu items. THESE ARE the only menu items that support icons and the only menu items that do not support checkboxes or radio buttons.

关于android - 添加带有子菜单项的图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12634171/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com