Class ListMenuItemView

All Implemented Interfaces:
Drawable.Callback, MenuView.ItemView, ViewManager, ViewParent, AbsListView.SelectionBoundsAdjuster

public class ListMenuItemView extends LinearLayout implements MenuView.ItemView, AbsListView.SelectionBoundsAdjuster
The item view for each item in the ListView-based MenuViews.
  • Constructor Details

    • ListMenuItemView

      public ListMenuItemView(Context context)
  • Method Details

    • initialize

      public void initialize(@NonNull MenuItemImpl itemData, int menuType)
      Description copied from interface: MenuView.ItemView
      Initializes with the provided MenuItemData. This should be called after the view is inflated.
      Specified by:
      initialize in interface MenuView.ItemView
      Parameters:
      itemData - The item that this ItemView should display.
      menuType - The type of this menu, one of
      invalid reference
      MenuBuilder#TYPE_ICON
      ,
      invalid reference
      MenuBuilder#TYPE_EXPANDED
      ,
      invalid reference
      MenuBuilder#TYPE_DIALOG
      ).
    • setForceShowIcon

      public void setForceShowIcon(boolean forceShow)
    • setTitle

      public void setTitle(@Nullable CharSequence title)
      Description copied from interface: MenuView.ItemView
      Sets the title of the item view.
      Specified by:
      setTitle in interface MenuView.ItemView
      Parameters:
      title - The title to set.
    • getItemData

      public MenuItemImpl getItemData()
      Description copied from interface: MenuView.ItemView
      Gets the item data that this view is displaying.
      Specified by:
      getItemData in interface MenuView.ItemView
      Returns:
      the item data, or null if there is not one
    • setCheckable

      public void setCheckable(boolean checkable)
      Description copied from interface: MenuView.ItemView
      Displays the checkbox for the item view. This does not ensure the item view will be checked, for that use MenuView.ItemView.setChecked(boolean).
      Specified by:
      setCheckable in interface MenuView.ItemView
      Parameters:
      checkable - Whether to display the checkbox or to hide it
    • setChecked

      public void setChecked(boolean checked)
      Description copied from interface: MenuView.ItemView
      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.
      Specified by:
      setChecked in interface MenuView.ItemView
      Parameters:
      checked - Whether the checkbox should be checked
    • setShortcut

      public void setShortcut(boolean showShortcut, char shortcutKey)
      Description copied from interface: MenuView.ItemView
      Sets the shortcut for the item.
      Specified by:
      setShortcut in interface MenuView.ItemView
      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.
    • setIcon

      public void setIcon(Drawable icon)
      Description copied from interface: MenuView.ItemView
      Set the icon of this item view.
      Specified by:
      setIcon in interface MenuView.ItemView
      Parameters:
      icon - The icon of this item. null to hide the icon.
    • onMeasure

      protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
      Description copied from class: View
      Measure the view and its content to determine the measured width and the measured height. This method is invoked by View.measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

      CONTRACT: When overriding this method, you must call View.setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by View.measure(int, int). Calling super.onMeasure() is a valid use.

      The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override the base one to provide better measurements of their content.

      Overrides:
      onMeasure in class LinearLayout
      Parameters:
      widthMeasureSpec - width measure specification imposed by the parent MeasureSpec
      heightMeasureSpec - height measure specification imposed by the parent MeasureSpec
    • prefersCondensedTitle

      public boolean prefersCondensedTitle()
      Description copied from interface: MenuView.ItemView
      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.
      Specified by:
      prefersCondensedTitle in interface MenuView.ItemView
      Returns:
      Whether this item view prefers displaying the condensed title.
    • showsIcon

      public boolean showsIcon()
      Description copied from interface: MenuView.ItemView
      Whether this item view shows an icon.
      Specified by:
      showsIcon in interface MenuView.ItemView
      Returns:
      Whether this item view shows an icon.
    • setGroupDividerEnabled

      public void setGroupDividerEnabled(boolean groupDividerEnabled)
      Enable or disable group dividers for this view.
    • adjustListItemSelectionBounds

      public void adjustListItemSelectionBounds(@NonNull Rect rect)
      Description copied from interface: AbsListView.SelectionBoundsAdjuster
      Called to allow the list item to adjust the bounds shown for its selection.
      Specified by:
      adjustListItemSelectionBounds in interface AbsListView.SelectionBoundsAdjuster
      Parameters:
      rect - On call, this contains the bounds the list has selected for the item (that is the bounds of the entire view). The values can be modified as desired.