Google se compromete a impulsar la igualdad racial para las comunidades afrodescendientes. Obtén información al respecto.

MenuItemCompat

class MenuItemCompat
kotlin.Any
   ↳ androidx.core.view.MenuItemCompat

Helper for accessing features in android.view.MenuItem.

Note: You cannot get an instance of this class. Instead, it provides static methods that correspond to the methods in , but take a android.view.MenuItem object as an additional argument.

Summary

Nested classes
abstract

Interface definition for a callback to be invoked when a menu item marked with is expanded or collapsed.

Constants
static Int

Always show this item as a button in an Action Bar.

static Int

This item's action view collapses to a normal menu item.

static Int

Show this item as a button in an Action Bar if the system decides there is room for it.

static Int

Never show this item as a button in an Action Bar.

static Int

When this item is in the action bar, always show it with a text label even if it also has an icon specified.

Public methods
static Boolean

Collapse the action view associated with this menu item.

static Boolean

Expand the action view associated with this menu item.

static ActionProvider!

Gets the ActionProvider.

static View!

Returns the currently set action view for this menu item.

static Int

Return the modifier for this menu item's alphabetic shortcut.

static CharSequence!

Retrieve the content description associated with this menu item.

static ColorStateList!

static Mode!

Returns the blending mode used to apply the tint to the item's icon, if specified.

static Int

Return the modifiers for this menu item's numeric (12-key) shortcut.

static CharSequence!

Retrieve the tooltip text associated with this menu item.

static Boolean

Returns true if this menu item's action view has been expanded.

static MenuItem!

Sets the ActionProvider responsible for creating an action view if the item is placed on the action bar.

static MenuItem!
setActionView(item: MenuItem!, view: View!)

Set an action view for this menu item.

static MenuItem!
setActionView(item: MenuItem!, resId: Int)

Set an action view for this menu item.

static Unit
setAlphabeticShortcut(item: MenuItem!, alphaChar: Char, alphaModifiers: Int)

Change the alphabetic shortcut associated with this item.

static Unit
setContentDescription(item: MenuItem!, contentDescription: CharSequence!)

Change the content description associated with this menu item.

static Unit

Applies a tint to the item's icon.

static Unit
setIconTintMode(item: MenuItem!, tintMode: Mode!)

Specifies the blending mode used to apply the tint specified by setIconTintList(MenuItem, ColorStateList) to the item's icon.

static Unit
setNumericShortcut(item: MenuItem!, numericChar: Char, numericModifiers: Int)

Change the numeric shortcut and modifiers associated with this item.

static MenuItem!

Set an OnActionExpandListener on this menu item to be notified when the associated action view is expanded or collapsed.

static Unit
setShortcut(item: MenuItem!, numericChar: Char, alphaChar: Char, numericModifiers: Int, alphaModifiers: Int)

Change both the numeric and alphabetic shortcut associated with this item.

static Unit
setShowAsAction(item: MenuItem!, actionEnum: Int)

Sets how this item should display in the presence of a compatible Action Bar.

static Unit
setTooltipText(item: MenuItem!, tooltipText: CharSequence!)

Change the tooltip text associated with this menu item.

Constants

SHOW_AS_ACTION_ALWAYS

static val SHOW_AS_ACTION_ALWAYS: Int

Deprecated: Use MenuItem#SHOW_AS_ACTION_ALWAYS directly.

Always show this item as a button in an Action Bar. Use sparingly! If too many items are set to always show in the Action Bar it can crowd the Action Bar and degrade the user experience on devices with smaller screens. A good rule of thumb is to have no more than 2 items set to always show at a time.

Value: 2

SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW

static val SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW: Int

Deprecated: Use MenuItem#SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW directly.

This item's action view collapses to a normal menu item. When expanded, the action view temporarily takes over a larger segment of its container.

Value: 8

SHOW_AS_ACTION_IF_ROOM

static val SHOW_AS_ACTION_IF_ROOM: Int

Deprecated: Use MenuItem#SHOW_AS_ACTION_IF_ROOM directly.

Show this item as a button in an Action Bar if the system decides there is room for it.

Value: 1

SHOW_AS_ACTION_NEVER

static val SHOW_AS_ACTION_NEVER: Int

Deprecated: Use MenuItem#SHOW_AS_ACTION_NEVER directly.

Never show this item as a button in an Action Bar.

Value: 0

SHOW_AS_ACTION_WITH_TEXT

static val SHOW_AS_ACTION_WITH_TEXT: Int

Deprecated: Use MenuItem#SHOW_AS_ACTION_WITH_TEXT directly.

When this item is in the action bar, always show it with a text label even if it also has an icon specified.

Value: 4

Public methods

collapseActionView

static fun collapseActionView(item: MenuItem!): Boolean

Deprecated: Use MenuItem#collapseActionView() directly.

Collapse the action view associated with this menu item. The menu item must have an action view set, as well as the showAsAction flag SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW. If a listener has been set using setOnActionExpandListener(MenuItem, * androidx.core.view.MenuItemCompat.OnActionExpandListener) it will have its method invoked. The listener may return false from this method to prevent collapsing the action view.

Return
Boolean true if the action view was collapsed, false otherwise.

expandActionView

static fun expandActionView(item: MenuItem!): Boolean

Deprecated: Use MenuItem#expandActionView() directly.

Expand the action view associated with this menu item. The menu item must have an action view set, as well as the showAsAction flag SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW. If a listener has been set using setOnActionExpandListener(MenuItem, OnActionExpandListener) it will have its OnActionExpandListener#onMenuItemActionExpand(MenuItem) method invoked. The listener may return false from this method to prevent expanding the action view.

Return
Boolean true if the action view was expanded, false otherwise.

getActionProvider

static fun getActionProvider(item: MenuItem!): ActionProvider!

Gets the ActionProvider.

Return
ActionProvider! The action provider.

getActionView

static fun getActionView(item: MenuItem!):