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)显示的文本。
见原文:
groupld | The group identifier that this item should be part of. This can be used to define groups of items for batch state changes. Normally useNONE 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. SeegetOrder() . |
title | The text to display for the item. |