MenuItemCompat

public final class MenuItemCompat
extends Object

java.lang.Object
   ↳ androidx.core.view.MenuItemCompat


Helper for accessing features in MenuItem.

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

Summary

Nested classes

interface MenuItemCompat.OnActionExpandListener

This interface is deprecated. Use MenuItem.OnActionExpandListener directly.  

Constants

int SHOW_AS_ACTION_ALWAYS

This constant is deprecated. Use MenuItem.SHOW_AS_ACTION_ALWAYS directly.

int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW

This constant is deprecated. Use MenuItem.SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW directly.

int SHOW_AS_ACTION_IF_ROOM

This constant is deprecated. Use MenuItem.SHOW_AS_ACTION_IF_ROOM directly.

int SHOW_AS_ACTION_NEVER

This constant is deprecated. Use MenuItem.SHOW_AS_ACTION_NEVER directly.

int SHOW_AS_ACTION_WITH_TEXT

This constant is deprecated. Use MenuItem.SHOW_AS_ACTION_WITH_TEXT directly.

Public methods

static boolean collapseActionView(MenuItem item)

This method is deprecated. Use MenuItem.collapseActionView() directly.

static boolean expandActionView(MenuItem item)

This method is deprecated. Use MenuItem.expandActionView() directly.

static ActionProvider getActionProvider(MenuItem item)

Gets the ActionProvider.

static View getActionView(MenuItem item)

This method is deprecated. Use MenuItem.getActionView() directly.

static int getAlphabeticModifiers(MenuItem item)

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

static CharSequence getContentDescription(MenuItem item)

Retrieve the content description associated with this menu item.

static ColorStateList getIconTintList(MenuItem item)
static PorterDuff.Mode getIconTintMode(MenuItem item)

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

static int getNumericModifiers(MenuItem item)

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

static CharSequence getTooltipText(MenuItem item)

Retrieve the tooltip text associated with this menu item.

static boolean isActionViewExpanded(MenuItem item)

This method is deprecated. Use MenuItem.isActionViewExpanded() directly.

static MenuItem setActionProvider(MenuItem item, ActionProvider provider)

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

static MenuItem setActionView(MenuItem item, int resId)

This method is deprecated. Use MenuItem.setActionView(int) directly.

static MenuItem setActionView(MenuItem item, View view)

This method is deprecated. Use MenuItem.setActionView(View) directly.

static void setAlphabeticShortcut(MenuItem item, char alphaChar, int alphaModifiers)

Change the alphabetic shortcut associated with this item.

static void setContentDescription(MenuItem item, CharSequence contentDescription)

Change the content description associated with this menu item.

static void setIconTintList(MenuItem item, ColorStateList tint)

Applies a tint to the item's icon.

static void setIconTintMode(MenuItem item, PorterDuff.Mode tintMode)

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

static void setNumericShortcut(MenuItem item, char numericChar, int numericModifiers)

Change the numeric shortcut and modifiers associated with this item.

static MenuItem setOnActionExpandListener(MenuItem item, MenuItemCompat.OnActionExpandListener listener)

This method is deprecated. Use MenuItem.setOnActionExpandListener(MenuItem.On