MenuItem.OnActionExpandListener, MenuItem.OnMenuItemClickListenerSHOW_AS_ACTION_ALWAYS, SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW, SHOW_AS_ACTION_IF_ROOM, SHOW_AS_ACTION_NEVER, SHOW_AS_ACTION_WITH_TEXT| Constructor and Description |
|---|
ActionMenuItem(android.content.Context context,
int group,
int id,
int categoryOrder,
int ordering,
CharSequence title) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
collapseActionView()
Collapse the action view associated with this menu item.
|
boolean |
expandActionView()
Expand the action view associated with this menu item.
|
ActionProvider |
getActionProvider()
Gets the
ActionProvider. |
android.view.View |
getActionView()
Returns the currently set action view for this menu item.
|
char |
getAlphabeticShortcut()
Return the char for this menu item's alphabetic shortcut.
|
int |
getGroupId()
Return the group identifier that this menu item is part of.
|
android.graphics.drawable.Drawable |
getIcon()
Returns the icon for this item as a Drawable (getting it from resources if it hasn't been
loaded before).
|
android.content.Intent |
getIntent()
Return the Intent associated with this item.
|
int |
getItemId()
Return the identifier for this menu item.
|
android.view.ContextMenu.ContextMenuInfo |
getMenuInfo()
Gets the extra information linked to this menu item.
|
char |
getNumericShortcut()
Return the char for this menu item's numeric (12-key) shortcut.
|
int |
getOrder()
Return the category and order within the category of this item.
|
SubMenu |
getSubMenu()
Get the sub-menu to be invoked when this item is selected, if it has
one.
|
CharSequence |
getTitle()
Retrieve the current title of the item.
|
CharSequence |
getTitleCondensed()
Retrieve the current condensed title of the item.
|
boolean |
hasSubMenu()
Check whether this item has an associated sub-menu.
|
boolean |
invoke() |
boolean |
isActionViewExpanded()
Returns true if this menu item's action view has been expanded.
|
boolean |
isCheckable()
Return whether the item can currently display a check mark.
|
boolean |
isChecked()
Return whether the item is currently displaying a check mark.
|
boolean |
isEnabled()
Return the enabled state of the menu item.
|
boolean |
isVisible()
Return the visibility of the menu item.
|
MenuItem |
setActionProvider(ActionProvider actionProvider)
Sets the
ActionProvider responsible for creating an action view if
the item is placed on the action bar. |
MenuItem |
setActionView(int resId)
Set an action view for this menu item.
|
MenuItem |
setActionView(android.view.View actionView)
Set an action view for this menu item.
|
MenuItem |
setAlphabeticShortcut(char alphaChar)
Change the alphabetic shortcut associated with this item.
|
MenuItem |
setCheckable(boolean checkable)
Control whether this item can display a check mark.
|
MenuItem |
setChecked(boolean checked)
Control whether this item is shown with a check mark.
|
MenuItem |
setEnabled(boolean enabled)
Sets whether the menu item is enabled.
|
ActionMenuItem |
setExclusiveCheckable(boolean exclusive) |
MenuItem |
setIcon(android.graphics.drawable.Drawable icon)
Change the icon associated with this item.
|
MenuItem |
setIcon(int iconRes)
Change the icon associated with this item.
|
MenuItem |
setIntent(android.content.Intent intent)
Change the Intent associated with this item.
|
MenuItem |
setNumericShortcut(char numericChar)
Change the numeric shortcut associated with this item.
|
MenuItem |
setOnActionExpandListener(MenuItem.OnActionExpandListener listener)
Set an
MenuItem.OnActionExpandListener on this menu item to be notified when
the associated action view is expanded or collapsed. |
MenuItem |
setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener)
Set a custom listener for invocation of this menu item.
|
MenuItem |
setShortcut(char numericChar,
char alphaChar)
Change both the numeric and alphabetic shortcut associated with this
item.
|
void |
setShowAsAction(int show)
Sets how this item should display in the presence of an Action Bar.
|
MenuItem |
setShowAsActionFlags(int actionEnum)
Sets how this item should display in the presence of an Action Bar.
|
MenuItem |
setTitle(CharSequence title)
Change the title associated with this item.
|
MenuItem |
setTitle(int title)
Change the title associated with this item.
|
MenuItem |
setTitleCondensed(CharSequence title)
Change the condensed title associated with this item.
|
MenuItem |
setVisible(boolean visible)
Sets the visibility of the menu item.
|
public ActionMenuItem(android.content.Context context,
int group,
int id,
int categoryOrder,
int ordering,
CharSequence title)
public char getAlphabeticShortcut()
MenuItemgetAlphabeticShortcut in interface MenuItempublic int getGroupId()
MenuItemgetGroupId in interface MenuItempublic android.graphics.drawable.Drawable getIcon()
MenuItempublic android.content.Intent getIntent()
MenuItemgetIntent in interface MenuItemMenuItem.setIntent(android.content.Intent), or
null.MenuItem.setIntent(android.content.Intent)public int getItemId()
MenuItempublic android.view.ContextMenu.ContextMenuInfo getMenuInfo()
MenuItemgetMenuInfo in interface MenuItemOnCreateContextMenuListenerpublic char getNumericShortcut()
MenuItemgetNumericShortcut in interface MenuItempublic int getOrder()
MenuItem
An order integer contains the item's category (the upper bits of the
integer; set by or/add the category with the order within the
category) and the ordering of the item within that category (the
lower bits). Example categories are Menu.CATEGORY_SYSTEM,
Menu.CATEGORY_SECONDARY, Menu.CATEGORY_ALTERNATIVE,
Menu.CATEGORY_CONTAINER. See Menu for a full list.
public SubMenu getSubMenu()
MenuItemMenuItem.hasSubMenu().getSubMenu in interface MenuItempublic CharSequence getTitle()
MenuItempublic CharSequence getTitleCondensed()
MenuItemgetTitleCondensed in interface MenuItempublic boolean hasSubMenu()
MenuItemhasSubMenu in interface MenuItempublic boolean isCheckable()
MenuItemisCheckable in interface MenuItemMenuItem.setCheckable(boolean)public boolean isChecked()
MenuItemisChecked in interface MenuItemMenuItem.setChecked(boolean)public boolean isEnabled()
MenuItempublic boolean isVisible()
MenuItempublic MenuItem setAlphabeticShortcut(char alphaChar)
MenuItem
See Menu for the menu types that support shortcuts.
setAlphabeticShortcut in interface MenuItemalphaChar - The alphabetic shortcut key. This is the shortcut when
using a keyboard with alphabetic keys.public MenuItem setCheckable(boolean checkable)
MenuItemMenuItem.setChecked(boolean) for that);
rather, it ensures there is room in the item in which to display a
check mark.
See Menu for the menu types that support check marks.
setCheckable in interface MenuItemcheckable - Set to true to allow a check mark, false to
disallow. The default is false.MenuItem.setChecked(boolean),
MenuItem.isCheckable(),
Menu.setGroupCheckable(int, boolean, boolean)public ActionMenuItem setExclusiveCheckable(boolean exclusive)
public MenuItem setChecked(boolean checked)
MenuItemMenuItem.setCheckable(boolean) or else
the check mark will not appear. If this item is a member of a group that contains
mutually-exclusive items (set via Menu.setGroupCheckable(int, boolean, boolean),
the other items in the group will be unchecked.
See Menu for the menu types that support check marks.
setChecked in interface MenuItemchecked - Set to true to display a check mark, false to hide
it. The default value is false.MenuItem.setCheckable(boolean),
MenuItem.isChecked(),
Menu.setGroupCheckable(int, boolean, boolean)public MenuItem setEnabled(boolean enabled)
MenuItemsetEnabled in interface MenuItemenabled - If true then the item will be invokable; if false it is
won't be invokable.public MenuItem setIcon(android.graphics.drawable.Drawable icon)
MenuItemMenu for the menu types that support icons.public MenuItem setIcon(int iconRes)
MenuItemMenu for the menu types that support icons.
This method will set the resource ID of the icon which will be used to lazily get the Drawable when this item is being shown.
public MenuItem setIntent(android.content.Intent intent)
MenuItemContext.startActivity(android.content.Intent) with the given Intent.
Note that setIntent() can not be used with the versions of
Menu.add(java.lang.CharSequence) that take a Runnable, because Runnable.run()
does not return a value so there is no way to tell if it handled the
item. In this case it is assumed that the Runnable always handles
the item, and the intent will never be started.
setIntent in interface MenuItemintent - The Intent to associated with the item. This Intent
object is not copied, so be careful not to
modify it later.MenuItem.getIntent()public MenuItem setNumericShortcut(char numericChar)
MenuItem
See Menu for the menu types that support shortcuts.
setNumericShortcut in interface MenuItemnumericChar - The numeric shortcut key. This is the shortcut when
using a 12-key (numeric) keyboard.public MenuItem setOnMenuItemClickListener(MenuItem.OnMenuItemClickListener menuItemClickListener)
MenuItemActivity#onOptionsItemSelected(MenuItem) or
Activity#onContextItemSelected(MenuItem).setOnMenuItemClickListener in interface MenuItemmenuItemClickListener - The object to receive invokations.Activity#onOptionsItemSelected(MenuItem),
Activity#onContextItemSelected(MenuItem)public MenuItem setShortcut(char numericChar, char alphaChar)
MenuItem
See Menu for the menu types that support shortcuts.
setShortcut in interface MenuItemnumericChar - The numeric shortcut key. This is the shortcut when
using a numeric (e.g., 12-key) keyboard.alphaChar - The alphabetic shortcut key. This is the shortcut when
using a keyboard with alphabetic keys.public MenuItem setTitle(CharSequence title)
MenuItempublic MenuItem setTitle(int title)
MenuItem
Some menu types do not sufficient space to show the full title, and
instead a condensed title is preferred. See Menu for more
information.
setTitle in interface MenuItemtitle - The resource id of the new text to be displayed.MenuItem.setTitleCondensed(CharSequence)public MenuItem setTitleCondensed(CharSequence title)
MenuItemsetTitleCondensed in interface MenuItemtitle - The new text to be displayed as the condensed title.public MenuItem setVisible(boolean visible)
MenuItemdisabled).setVisible in interface MenuItemvisible - If true then the item will be visible; if false it is
hidden.public boolean invoke()
public void setShowAsAction(int show)
MenuItemMenuItem.SHOW_AS_ACTION_ALWAYS,
MenuItem.SHOW_AS_ACTION_IF_ROOM, or MenuItem.SHOW_AS_ACTION_NEVER should
be used, and you may optionally OR the value with MenuItem.SHOW_AS_ACTION_WITH_TEXT.
SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action,
it should be shown with a text label.setShowAsAction in interface MenuItemshow - How the item should display. One of
MenuItem.SHOW_AS_ACTION_ALWAYS, MenuItem.SHOW_AS_ACTION_IF_ROOM, or
MenuItem.SHOW_AS_ACTION_NEVER. SHOW_AS_ACTION_NEVER is the default.ActionBar,
MenuItem.setActionView(View)public MenuItem setActionView(android.view.View actionView)
MenuItem
Note: Setting an action view overrides the action provider
set via MenuItem.setActionProvider(ActionProvider).
setActionView in interface MenuItemactionView - View to use for presenting this item to the user.MenuItem.setShowAsAction(int)public android.view.View getActionView()
MenuItemgetActionView in interface MenuItemMenuItem.setActionView(View),
MenuItem.setShowAsAction(int)public MenuItem setActionView(int resId)
MenuItem
Note: Setting an action view overrides the action provider
set via MenuItem.setActionProvider(ActionProvider).
setActionView in interface MenuItemresId - Layout resource to use for presenting this item to the user.MenuItem.setShowAsAction(int)public ActionProvider getActionProvider()
MenuItemActionProvider.getActionProvider in interface MenuItemActionProvider,
MenuItem.setActionProvider(ActionProvider)public MenuItem setActionProvider(ActionProvider actionProvider)
MenuItemActionProvider responsible for creating an action view if
the item is placed on the action bar. The provider also provides a default
action invoked if the item is placed in the overflow menu.
Note: Setting an action provider overrides the action view
set via MenuItem.setActionView(int) or MenuItem.setActionView(View).
setActionProvider in interface MenuItemactionProvider - The action provider.ActionProviderpublic MenuItem setShowAsActionFlags(int actionEnum)
MenuItemMenuItem.SHOW_AS_ACTION_ALWAYS,
MenuItem.SHOW_AS_ACTION_IF_ROOM, or MenuItem.SHOW_AS_ACTION_NEVER should
be used, and you may optionally OR the value with MenuItem.SHOW_AS_ACTION_WITH_TEXT.
SHOW_AS_ACTION_WITH_TEXT requests that when the item is shown as an action,
it should be shown with a text label.
Note: This method differs from MenuItem.setShowAsAction(int) only in that it
returns the current MenuItem instance for call chaining.
setShowAsActionFlags in interface MenuItemactionEnum - How the item should display. One of
MenuItem.SHOW_AS_ACTION_ALWAYS, MenuItem.SHOW_AS_ACTION_IF_ROOM, or
MenuItem.SHOW_AS_ACTION_NEVER. SHOW_AS_ACTION_NEVER is the default.ActionBar,
MenuItem.setActionView(View)public boolean expandActionView()
MenuItemMenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW.
If a listener has been set using MenuItem.setOnActionExpandListener(OnActionExpandListener)
it will have its MenuItem.OnActionExpandListener.onMenuItemActionExpand(MenuItem)
method invoked. The listener may return false from this method to prevent expanding
the action view.expandActionView in interface MenuItempublic boolean collapseActionView()
MenuItemMenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW. If a listener has been set using
MenuItem.setOnActionExpandListener(OnActionExpandListener) it will have its
MenuItem.OnActionExpandListener.onMenuItemActionCollapse(MenuItem) method invoked.
The listener may return false from this method to prevent collapsing the action view.collapseActionView in interface MenuItempublic boolean isActionViewExpanded()
MenuItemisActionViewExpanded in interface MenuItemMenuItem.expandActionView(),
MenuItem.collapseActionView(),
MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW,
MenuItem.OnActionExpandListenerpublic MenuItem setOnActionExpandListener(MenuItem.OnActionExpandListener listener)
MenuItemMenuItem.OnActionExpandListener on this menu item to be notified when
the associated action view is expanded or collapsed. The menu item must
be configured to expand or collapse its action view using the flag
MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW.setOnActionExpandListener in interface MenuItemlistener - Listener that will respond to expand/collapse eventsCopyright © 2011–2014. All rights reserved.