您的位置:首页 > 移动开发 > Android开发

android中menu.add()的使用

2013-11-16 21:22 316 查看
public boolean onCreateOptionsMenu(Menu menu) {
// 增加一个选择菜单,点击手机“设置”键时弹出
menu.add(0, 1, 1, "退出");
return super.onCreateOptionsMenu(menu);
}

附:

add(int groupId, int itemId, int order, CharSequence title)
groupId 组标示符应该是这个项(item)的一部分。可以用来定义项(items)中批量状态改变的组。如果一个项(item)不应该在一组一般使用NONE。
itemId 唯一的项ID。如果你不需要一个唯一ID,可以用NONE。
order 项(item)的排序,如果不需要排序可以使用NONE。
title 项(item)显示的文本。


见原文:

add(int
groupId, int itemId,int order,CharSequence title)

groupldThe group identifier that this item should be part of. This can be used to define groups of items for batch state changes. Normally use
NONE

if an item should not be in a group.
itemIdUnique item ID. Use
NONE
if you do not need a unique ID.
orderThe order for the item. Use
NONE
if you do not care about the order. See
getOrder()
.
titleThe text to display for the item.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: