public interface

MenuView.ItemView

 androidx.appcompat.view.menu.MenuView.ItemView

Subclasses:

ListMenuItemView, ActionMenuItemView

Overview

Minimal interface for a menu item view. MenuView.ItemView.initialize(MenuItemImpl, int) must be called for the item to be functional.

Summary

Methods
public MenuItemImplgetItemData()

Gets the item data that this view is displaying.

public voidinitialize(MenuItemImpl itemData, int menuType)

Initializes with the provided MenuItemData.

public booleanprefersCondensedTitle()

Whether this item view prefers displaying the condensed title rather than the normal title.

public voidsetCheckable(boolean checkable)

Displays the checkbox for the item view.

public voidsetChecked(boolean checked)

Checks the checkbox for the item view.

public voidsetEnabled(boolean enabled)

Sets the enabled state of the item view.

public voidsetIcon(Drawable icon)

Set the icon of this item view.

public voidsetShortcut(boolean showShortcut, char shortcutKey)

Sets the shortcut for the item.

public voidsetTitle(java.lang.CharSequence title)

Sets the title of the item view.

public booleanshowsIcon()

Whether this item view shows an icon.

Methods

public void initialize(MenuItemImpl itemData, int menuType)

Initializes with the provided MenuItemData. This should be called after the view is inflated.

Parameters:

itemData: The item that this ItemView should display.
menuType: The type of this menu, one of MenuBuilder, MenuBuilder, MenuBuilder).

public MenuItemImpl getItemData()

Gets the item data that this view is displaying.

Returns:

the item data, or null if there is not one

public void setTitle(java.lang.CharSequence title)

Sets the title of the item view.

Parameters:

title: The title to set.

public void setEnabled(boolean enabled)

Sets the enabled state of the item view.

Parameters:

enabled: Whether the item view should be enabled.

public void setCheckable(boolean checkable)

Displays the checkbox for the item view. This does not ensure the item view will be checked, for that use MenuView.ItemView.setChecked(boolean).

Parameters:

checkable: Whether to display the checkbox or to hide it

public void setChecked(boolean checked)

Checks the checkbox for the item view. If the checkbox is hidden, it will NOT be made visible, call MenuView.ItemView.setCheckable(boolean) for that.

Parameters:

checked: Whether the checkbox should be checked

public void setShortcut(boolean showShortcut, char shortcutKey)

Sets the shortcut for the item.

Parameters:

showShortcut: Whether a shortcut should be shown(if false, the value of shortcutKey should be ignored).
shortcutKey: The shortcut key that should be shown on the ItemView.

public void setIcon(Drawable icon)

Set the icon of this item view.

Parameters:

icon: The icon of this item. null to hide the icon.

public boolean prefersCondensedTitle()

Whether this item view prefers displaying the condensed title rather than the normal title. If a condensed title is not available, the normal title will be used.

Returns:

Whether this item view prefers displaying the condensed title.

public boolean showsIcon()

Whether this item view shows an icon.

Returns:

Whether this item view shows an icon.