Fields Summary |
---|
static final int | USER_MASKThis is the part of an order integer that the user can provide. |
static final int | USER_SHIFTBit shift of the user portion of the order integer. |
static final int | CATEGORY_MASKThis is the part of an order integer that supplies the category of the
item. |
static final int | CATEGORY_SHIFTBit shift of the category portion of the order integer. |
static final int | NONEValue to use for group and item identifier integers when you don't care
about them. |
static final int | FIRSTFirst value for group and item identifier integers. |
static final int | CATEGORY_CONTAINERCategory code for the order integer for items/groups that are part of a
container -- or/add this with your base value. |
static final int | CATEGORY_SYSTEMCategory code for the order integer for items/groups that are provided by
the system -- or/add this with your base value. |
static final int | CATEGORY_SECONDARYCategory code for the order integer for items/groups that are
user-supplied secondary (infrequently used) options -- or/add this with
your base value. |
static final int | CATEGORY_ALTERNATIVECategory code for the order integer for items/groups that are
alternative actions on the data that is currently displayed -- or/add
this with your base value. |
static final int | FLAG_APPEND_TO_GROUPFlag for {@link #addIntentOptions}: if set, do not automatically remove
any existing menu items in the same group. |
static final int | FLAG_PERFORM_NO_CLOSEFlag for {@link #performShortcut}: if set, do not close the menu after
executing the shortcut. |
static final int | FLAG_ALWAYS_PERFORM_CLOSEFlag for {@link #performShortcut(int, KeyEvent, int)}: if set, always
close the menu after executing the shortcut. Closing the menu also resets
the prepared state. |
Methods Summary |
---|
public MenuItem | add(java.lang.CharSequence title)Add a new item to the menu. This item displays the given title for its
label.
|
public MenuItem | add(int titleRes)Add a new item to the menu. This item displays the given title for its
label.
|
public MenuItem | add(int groupId, int itemId, int order, java.lang.CharSequence title)Add a new item to the menu. This item displays the given title for its
label.
|
public MenuItem | add(int groupId, int itemId, int order, int titleRes)Variation on {@link #add(int, int, int, CharSequence)} that takes a
string resource identifier instead of the string itself.
|
public int | addIntentOptions(int groupId, int itemId, int order, android.content.ComponentName caller, android.content.Intent[] specifics, android.content.Intent intent, int flags, MenuItem[] outSpecificItems)Add a group of menu items corresponding to actions that can be performed
for a particular Intent. The Intent is most often configured with a null
action, the data that the current activity is working with, and includes
either the {@link Intent#CATEGORY_ALTERNATIVE} or
{@link Intent#CATEGORY_SELECTED_ALTERNATIVE} to find activities that have
said they would like to be included as optional action. You can, however,
use any Intent you want.
See {@link android.content.pm.PackageManager#queryIntentActivityOptions}
for more * details on the caller, specifics, and
intent arguments. The list returned by that function is used
to populate the resulting menu items.
All of the menu items of possible options for the intent will be added
with the given group and id. You can use the group to control ordering of
the items in relation to other items in the menu. Normally this function
will automatically remove any existing items in the menu in the same
group and place a divider above and below the added items; this behavior
can be modified with the flags parameter. For each of the
generated items {@link MenuItem#setIntent} is called to associate the
appropriate Intent with the item; this means the activity will
automatically be started for you without having to do anything else.
|
public SubMenu | addSubMenu(java.lang.CharSequence title)Add a new sub-menu to the menu. This item displays the given title for
its label. To modify other attributes on the submenu's menu item, use
{@link SubMenu#getItem()}.
|
public SubMenu | addSubMenu(int titleRes)Add a new sub-menu to the menu. This item displays the given title for
its label. To modify other attributes on the submenu's menu item, use
{@link SubMenu#getItem()}.
|
public SubMenu | addSubMenu(int groupId, int itemId, int order, java.lang.CharSequence title)Add a new sub-menu to the menu. This item displays the given
title for its label. To modify other attributes on the
submenu's menu item, use {@link SubMenu#getItem()}.
Note that you can only have one level of sub-menus, i.e. you cannnot add
a subMenu to a subMenu: An {@link UnsupportedOperationException} will be
thrown if you try.
|
public SubMenu | addSubMenu(int groupId, int itemId, int order, int titleRes)Variation on {@link #addSubMenu(int, int, int, CharSequence)} that takes
a string resource identifier for the title instead of the string itself.
|
public void | clear()Remove all existing items from the menu, leaving it empty as if it had
just been created.
|
public void | close()Closes the menu, if open.
|
public MenuItem | findItem(int id)Return the menu item with a particular identifier.
|
public MenuItem | getItem(int index)Gets the menu item at the given index.
|
public boolean | hasVisibleItems()Return whether the menu currently has item items that are visible.
|
public boolean | isShortcutKey(int keyCode, KeyEvent event)Is a keypress one of the defined shortcut keys for this window.
|
public boolean | performIdentifierAction(int id, int flags)Execute the menu item action associated with the given menu identifier.
|
public boolean | performShortcut(int keyCode, KeyEvent event, int flags)Execute the menu item action associated with the given shortcut
character.
|
public void | removeGroup(int groupId)Remove all items in the given group.
|
public void | removeItem(int id)Remove the item with the given identifier.
|
public void | setGroupCheckable(int group, boolean checkable, boolean exclusive)Control whether a particular group of items can show a check mark. This
is similar to calling {@link MenuItem#setCheckable} on all of the menu items
with the given group identifier, but in addition you can control whether
this group contains a mutually-exclusive set items. This should be called
after the items of the group have been added to the menu.
|
public void | setGroupEnabled(int group, boolean enabled)Enable or disable all menu items that are in the given group.
|
public void | setGroupVisible(int group, boolean visible)Show or hide all menu items that are in the given group.
|
public void | setQwertyMode(boolean isQwerty)Control whether the menu should be running in qwerty mode (alphabetic
shortcuts) or 12-key mode (numeric shortcuts).
|
public int | size()Get the number of items in the menu. Note that this will change any
times items are added or removed from the menu.
|