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.

  • 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)