Package icyllis.modernui.view.menu

# Class ContextMenuBuilder

java.lang.Object
icyllis.modernui.view.menu.MenuBuilder
icyllis.modernui.view.menu.ContextMenuBuilder

All Implemented Interfaces:
  `ContextMenu`, `Menu`

public class ContextMenuBuilder extends MenuBuilder implements ContextMenu
Implementation of the `ContextMenu` interface.

Most clients of the menu framework will never need to touch this class. However, if the client has a window that is not a content view of a Dialog or Activity (for example, the view was added directly to the window manager) and needs to show context menus, it will use this class.

To use this class, instantiate it via `ContextMenuBuilder(Context)`, and optionally populate it with any of your custom items. Finally, call `showPopup(Context, View, float, float)` which will populate the menu with a view's context menu items and show the context menu.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class icyllis.modernui.view.menu.MenuBuilder

  `MenuBuilder.Callback, MenuBuilder.ItemInvoker`

  ## Nested classes/interfaces inherited from interface icyllis.modernui.view.ContextMenu

  `ContextMenu.ContextMenuInfo`

- ## Field Summary

  ### Fields inherited from interface icyllis.modernui.view.Menu

  `CATEGORY_ALTERNATIVE, CATEGORY_CONTAINER, CATEGORY_MASK, CATEGORY_SECONDARY, CATEGORY_SHIFT, CATEGORY_SYSTEM, FIRST, FLAG_ALWAYS_PERFORM_CLOSE, FLAG_PERFORM_NO_CLOSE, NONE, SUPPORTED_MODIFIERS_MASK, USER_MASK, USER_SHIFT`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ContextMenuBuilder(Context context)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ContextMenu`
  `setHeaderIcon(Drawable icon)`
  Sets the context menu header's icon to the icon given in icon `Drawable`.
  `ContextMenu`
  `setHeaderTitle(CharSequence title)`
  Sets the context menu header's title to the title given in title.
  `ContextMenu`
  `setHeaderView(View view)`
  Sets the header of the context menu to the `View` given in view.
  `MenuPopupHelper`
  `showPopup(Context context, View originalView, float x, float y)`

  ### Methods inherited from class icyllis.modernui.view.menu.MenuBuilder

  `add, add, addMenuPresenter, addMenuPresenter, addSubMenu, addSubMenu, changeMenuMode, clear, clearAll, clearHeader, close, close, collapseItemActionView, expandItemActionView, findGroupIndex, findGroupIndex, findItem, findItemIndex, flagActionItems, getActionItems, getContext, getExpandedItem, getHeaderIcon, getHeaderTitle, getHeaderView, getItem, getNonActionItems, getRootMenu, getVisibleItems, hasVisibleItems, isGroupDividerEnabled, isShortcutKey, isShortcutsVisible, onItemsChanged, performIdentifierAction, performItemAction, performItemAction, performShortcut, removeGroup, removeItem, removeItemAt, removeMenuPresenter, setCallback, setCurrentMenuInfo, setDefaultShowAsAction, setGroupCheckable, setGroupDividerEnabled, setGroupEnabled, setGroupVisible, setHeaderIconInt, setHeaderTitleInt, setHeaderViewInt, setOptionalIconsVisible, setQwertyMode, setShortcutsVisible, size, startDispatchingItemsChanged, stopDispatchingItemsChanged`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface icyllis.modernui.view.ContextMenu

  `clearHeader`

  ### Methods inherited from interface icyllis.modernui.view.Menu

  `add, add, addSubMenu, addSubMenu, clear, close, findItem, getItem, hasVisibleItems, isShortcutKey, performIdentifierAction, performShortcut, removeGroup, removeItem, setGroupCheckable, setGroupDividerEnabled, setGroupEnabled, setGroupVisible, setQwertyMode, size`

- ## Constructor Details

  - ### ContextMenuBuilder

    public ContextMenuBuilder(Context context)

- ## Method Details

  - ### setHeaderIcon

    @NonNull public ContextMenu setHeaderIcon(Drawable icon)
    Description copied from interface: `ContextMenu`
    Sets the context menu header's icon to the icon given in icon `Drawable`.
    Specified by:
      `setHeaderIcon` in interface `ContextMenu`
    Parameters:
      `icon` - The `Drawable` used for the icon.
    Returns:
      This ContextMenu so additional setters can be called.

  - ### setHeaderTitle

    @NonNull public ContextMenu setHeaderTitle(CharSequence title)
    Description copied from interface: `ContextMenu`
    Sets the context menu header's title to the title given in title.
    Specified by:
      `setHeaderTitle` in interface `ContextMenu`
    Parameters:
      `title` - The character sequence used for the title.
    Returns:
      This ContextMenu so additional setters can be called.

  - ### setHeaderView

    @NonNull public ContextMenu setHeaderView(View view)
    Description copied from interface: `ContextMenu`
    Sets the header of the context menu to the `View` given in view. This replaces the header title and icon (and those replace this).
    Specified by:
      `setHeaderView` in interface `ContextMenu`
    Parameters:
      `view` - The `View` used for the header.
    Returns:
      This ContextMenu so additional setters can be called.

  - ### showPopup

    public MenuPopupHelper showPopup(Context context, View originalView, float x, float y)