belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1
MenuItemCompat
public
final
class
MenuItemCompat
extends Object
java.lang.Object | |
↳ | android.support.v4.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 was deprecated
in API level 26.1.0.
Use |
Constants | |
---|---|
int |
SHOW_AS_ACTION_ALWAYS
This constant was deprecated
in API level 26.1.0.
Use |
int |
SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
This constant was deprecated
in API level 26.1.0.
Use |
int |
SHOW_AS_ACTION_IF_ROOM
This constant was deprecated
in API level 26.1.0.
Use |
int |
SHOW_AS_ACTION_NEVER
This constant was deprecated
in API level 26.1.0.
Use |
int |
SHOW_AS_ACTION_WITH_TEXT
This constant was deprecated
in API level 26.1.0.
Use |
Public methods | |
---|---|
static
boolean
|
collapseActionView(MenuItem item)
This method was deprecated
in API level 26.1.0.
Use |
static
boolean
|
expandActionView(MenuItem item)
This method was deprecated
in API level 26.1.0.
Use |
static
ActionProvider
|
getActionProvider(MenuItem item)
Gets the |
static
View
|
getActionView(MenuItem item)
This method was deprecated
in API level 26.1.0.
Use |
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 was deprecated
in API level 26.1.0.
Use |
static
MenuItem
|
setActionProvider(MenuItem item, ActionProvider provider)
Sets the |
static
MenuItem
|
setActionView(MenuItem item, int resId)
This method was deprecated
in API level 26.1.0.
Use |
static
MenuItem
|
setActionView(MenuItem item, View view)
This method was deprecated
in API level 26.1.0.
Use |
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
|
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 was deprecated
in API level 26.1.0.
Use |
static
void
|
setShortcut(MenuItem item, char numericChar, char alphaChar, int numericModifiers, int alphaModifiers)
Change both the numeric and alphabetic shortcut associated with this item. |
static
void
|
setShowAsAction(MenuItem item, int actionEnum)
This method was deprecated
in API level 26.1.0.
Use |
static
void
|
setTooltipText(MenuItem item, CharSequence tooltipText)
Change the tooltip text associated with this menu item. |
Inherited methods | |
---|---|
![]()
java.lang.Object
|
Constants
SHOW_AS_ACTION_ALWAYS
int SHOW_AS_ACTION_ALWAYS
This constant was deprecated
in API level 26.1.0.
Use 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.
Constant Value: 2 (0x00000002)
SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
int SHOW_AS_ACTION_COLLAPSE_ACTION_VIEW
This constant was deprecated
in API level 26.1.0.
Use 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.
Constant Value: 8 (0x00000008)
SHOW_AS_ACTION_IF_ROOM
int SHOW_AS_ACTION_IF_ROOM
This constant was deprecated
in API level 26.1.0.
Use 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.
Constant Value: 1 (0x00000001)
SHOW_AS_ACTION_NEVER
int SHOW_AS_ACTION_NEVER
This constant was deprecated
in API level 26.1.0.
Use SHOW_AS_ACTION_NEVER
directly.
Never show this item as a button in an Action Bar.
Constant Value: 0 (0x00000000)
SHOW_AS_ACTION_WITH_TEXT
int SHOW_AS_ACTION_WITH_TEXT
This constant was deprecated
in API level 26.1.0.
Use 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.
Constant Value: 4 (0x00000004)
Public methods
collapseActionView
boolean collapseActionView (MenuItem item)
This method was deprecated
in API level 26.1.0.
Use 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, android.support.v4.view.MenuItemCompat.OnActionExpandListener)
it will have its onMenuItemActionCollapse(MenuItem)
method invoked. The listener may return false from this method to prevent collapsing
the action view.
Parameters | |
---|---|
item |
MenuItem |
Returns | |
---|---|
boolean |
true if the action view was collapsed, false otherwise. |
expandActionView
boolean expandActionView (MenuItem item)
This method was deprecated
in API level 26.1.0.
Use 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 onMenuItemActionExpand(MenuItem)
method invoked. The listener may return false from this method to prevent expanding
the action view.
Parameters | |
---|---|
item |
MenuItem |
Returns | |
---|---|
boolean |
true if the action view was expanded, false otherwise. |
getActionProvider
ActionProvider getActionProvider (MenuItem item)
Gets the ActionProvider
.
Parameters | |
---|---|
item |
MenuItem |
Returns | |
---|---|
ActionProvider |
The action provider. |
getActionView
View getActionView (MenuItem item)
This method was deprecated
in API level 26.1.0.
Use getActionView()
directly.
Returns the currently set action view for this menu item.
Parameters | |
---|---|
item |
MenuItem : the item to query |
Returns | |
---|---|
View |
This item's action view |