SubMenu


public interface SubMenu
implements Menu

android.view.SubMenu


Subclass of Menu for sub menus.

Sub menus do not support item icons, or nested sub menus.

Developer Guides

For information about creating menus, read the Menus developer guide.

Summary

Inherited constants

int CATEGORY_ALTERNATIVE

Category 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.

int CATEGORY_CONTAINER

Category code for the order integer for items/groups that are part of a container -- or/add this with your base value.

int CATEGORY_SECONDARY

Category code for the order integer for items/groups that are user-supplied secondary (infrequently used) options -- or/add this with your base value.

int CATEGORY_SYSTEM

Category code for the order integer for items/groups that are provided by the system -- or/add this with your base value.

int FIRST

First value for group and item identifier integers.

int FLAG_ALWAYS_PERFORM_CLOSE

Flag for performShortcut(int, android.view.KeyEvent, int): if set, always close the menu after executing the shortcut.

int FLAG_APPEND_TO_GROUP

Flag for addIntentOptions(int, int, int, ComponentName, Intent, Intent, int, MenuItem): if set, do not automatically remove any existing menu items in the same group.

int FLAG_PERFORM_NO_CLOSE

Flag for performShortcut(int, KeyEvent, int): if set, do not close the menu after executing the shortcut.

int NONE

Value to use for group and item identifier integers when you don't care about them.

int SUPPORTED_MODIFIERS_MASK

A mask of all supported modifiers for MenuItem's keyboard shortcuts

Public methods

abstract void clearHeader()

Clears the header of the submenu.

abstract MenuItem getItem()

Gets the MenuItem that represents this submenu in the parent menu.

abstract SubMenu setHeaderIcon(int iconRes)

Sets the submenu header's icon to the icon given in iconRes resource id.

abstract SubMenu setHeaderIcon(Drawable icon)

Sets the submenu header's icon to the icon given in icon Drawable.

abstract SubMenu setHeaderTitle(int titleRes)

Sets the submenu header's title to the title given in titleRes resource identifier.

abstract SubMenu setHeaderTitle(CharSequence title)

Sets the submenu header's title to the title given in title.

abstract SubMenu setHeaderView(View view)

Sets the header of the submenu to the View given in view.

abstract SubMenu setIcon(Drawable icon)

Change the icon associated with this submenu's item in its parent menu.

abstract SubMenu setIcon(int iconRes)

Change the icon associated with this submenu's item in its parent menu.

Inherited methods

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

Add a new item to the menu.

abstract MenuItem add(int titleRes)

Add a new item to the menu.

abstract MenuItem add(CharSequence title)

Add a new item to the menu.

abstract MenuItem add(int groupId, int itemId, int order, int titleRes)

Variation on add(int, int, int, java.lang.CharSequence) that takes a string resource identifier instead of the string itself.

abstract int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems)

Add a group of menu items corresponding to actions that can be performed for a particular Intent.

abstract SubMenu addSubMenu(CharSequence title)

Add a new sub-menu to the menu.

abstract SubMenu addSubMenu(int groupId, int itemId, int order, int titleRes)

Variation on addSubMenu(int, int, int, java.lang.CharSequence) that takes a string resource identifier for the title instead of the string itself.

abstract SubMenu addSubMenu(int groupId, int itemId, int order, CharSequence title)

Add a new sub-menu to the menu.

abstract SubMenu addSubMenu(int titleRes)

Add a new sub-menu to the menu.

abstract void clear()

Remove all existing items from the menu, leaving it empty as if it had just been created.

abstract void close()

Closes the menu, if open.

abstract MenuItem findItem(int id)

Return the menu item with a particular identifier.

abstract MenuItem getItem(int index)

Gets the menu item at the given index.

abstract boolean hasVisibleItems()

Return whether the menu currently has item items that are visible.

abstract boolean isShortcutKey(int keyCode, KeyEvent event)

Is a keypress one of the defined shortcut keys for this window.

abstract boolean performIdentifierAction(int id, int flags)

Execute the menu item action associated with the given menu identifier.

abstract boolean performShortcut(int keyCode, KeyEvent event, int flags)

Execute the menu item action associated with the given shortcut character.

abstract void removeGroup(int groupId)

Remove all items in the given group.

abstract void removeItem(int id)

Remove the item with the given identifier.

abstract void setGroupCheckable(int group, boolean checkable, boolean exclusive)

Control whether a particular group of items can show a check mark.

default void setGroupDividerEnabled(boolean groupDividerEnabled)

Enable or disable the group dividers.

abstract void setGroupEnabled(int group, boolean enabled)

Enable or disable all menu items that are in the given group.

abstract void setGroupVisible(int group, boolean visible)

Show or hide all menu items that are in the given group.

abstract void setQwertyMode(boolean isQwerty)

Control whether the menu should be running in qwerty mode (alphabetic shortcuts) or 12-key mode (numeric shortcuts).

abstract int size()

Get the number of items in the menu.

Public methods

clearHeader

Added in API level 1
public abstract void clearHeader ()

Clears the header of the submenu.

getItem

Added in API level 1
public abstract MenuItem getItem ()

Gets the MenuItem that represents this submenu in the parent menu. Use this for setting additional item attributes.

Returns
MenuItem The MenuItem that launches the submenu when invoked.

setHeaderIcon

Added in API level 1
public abstract SubMenu setHeaderIcon (int iconRes)

Sets the submenu header's icon to the icon given in iconRes resource id.

Parameters
iconRes int: The resource identifier used for the icon.

Returns
SubMenu This SubMenu so additional setters can be called.

setHeaderIcon

Added in API level 1
public abstract SubMenu setHeaderIcon (Drawable icon)

Sets the submenu header's icon to the icon given in icon Drawable.

Parameters
icon Drawable: The Drawable used for the icon.

Returns
SubMenu This SubMenu so additional setters can be called.

setHeaderTitle

Added in API level 1
public abstract SubMenu setHeaderTitle (int titleRes)

Sets the submenu header's title to the title given in titleRes resource identifier.

Parameters
titleRes int: The string resource identifier used for the title.

Returns
SubMenu This SubMenu so additional setters can be called.

setHeaderTitle

Added in API level 1
public abstract SubMenu setHeaderTitle (CharSequence title)

Sets the submenu header's title to the title given in title.

Parameters
title CharSequence: The character sequence used for the title.

Returns
SubMenu This SubMenu so additional setters can be called.

setHeaderView

Added in API level 1
public abstract SubMenu setHeaderView (View view)

Sets the header of the submenu to the View given in view. This replaces the header title and icon (and those replace this).

Parameters
view View: The View used for the header.

Returns
SubMenu This SubMenu so additional setters can be called.

setIcon

Added in API level 1
public abstract SubMenu setIcon (Drawable icon)

Change the icon associated with this submenu's item in its parent menu.

Parameters
icon Drawable: The new icon (as a Drawable) to be displayed.

Returns
SubMenu This SubMenu so additional setters can be called.

setIcon

Added in API level 1
public abstract SubMenu setIcon (int iconRes)

Change the icon associated with this submenu's item in its parent menu.

Parameters
iconRes int: The new icon (as a resource ID) to be displayed.

Returns
SubMenu This SubMenu so additional setters can be called.