Android中Menu控件的add方法

public abstract MenuItem add (int groupId, int itemId, int order, int titleRes) 
Added in API level 1
Variation on add(int, int, int, CharSequence) that takes a string resource identifier instead of the string itself.

Parameters
groupId  The group identifier that this item should be part of. This can also be used to define groups of items for batch state changes. Normally use NONE if an item should not be in a group. 
itemId  Unique item ID. Use NONE if you do not need a unique ID. 
order  The order for the item. Use NONE if you do not care about the order. See getOrder(). 
titleRes  Resource identifier of title string. 

Returns
The newly added menu item. 


 

 

第一个int类型的group ID参数,代表的是组概念,你可以将几个菜单项归为一组,以便更好的以组的方式管理你的菜单按钮。
第二个int类型的item ID参数,代表的是项目编号。这个参数非常重要,一个item ID对应一个menu中的选项。在后面使用菜单的时候,就靠这个item ID来判断你使用的是哪个选项。
第三个int类型的order ID参数,代表的是菜单项的显示顺序。默认是0,表示菜单的显示顺序就是按照add的显示顺序来显示。
第四个String类型的title参数,表示选项中显示的文字。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值