public class ContextMenuBuilder extends MenuBuilder implements ContextMenu
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 showDialog(View, IBinder)
which will populate the menu
with a view's context menu items and show the context menu.
MenuBuilder.Callback, MenuBuilder.ItemInvoker
ContextMenu.ContextMenuInfo
CATEGORY_ALTERNATIVE, CATEGORY_CONTAINER, CATEGORY_MASK, CATEGORY_SECONDARY, CATEGORY_SHIFT, CATEGORY_SYSTEM, FIRST, FLAG_ALWAYS_PERFORM_CLOSE, FLAG_APPEND_TO_GROUP, FLAG_PERFORM_NO_CLOSE, NONE, USER_MASK, USER_SHIFT
Constructor and Description |
---|
ContextMenuBuilder(Context context) |
Modifier and Type | Method and Description |
---|---|
ContextMenu |
setHeaderIcon(Drawable icon)
Sets the context menu header's icon to the icon given in icon
Drawable . |
ContextMenu |
setHeaderIcon(int iconRes)
Sets the context menu header's icon to the icon given in iconRes
resource id.
|
ContextMenu |
setHeaderTitle(CharSequence title)
Sets the context menu header's title to the title given in title.
|
ContextMenu |
setHeaderTitle(int titleRes)
Sets the context menu header's title to the title given in titleRes
resource identifier.
|
ContextMenu |
setHeaderView(View view)
Sets the header of the context menu to the
View given in
view. |
MenuDialogHelper |
showDialog(View originalView,
IBinder token)
Shows this context menu, allowing the optional original view (and its
ancestors) to add items.
|
MenuPopupHelper |
showPopup(Context context,
View originalView,
float x,
float y) |
add, add, add, add, addIntentOptions, addMenuPresenter, addMenuPresenter, addSubMenu, addSubMenu, addSubMenu, addSubMenu, changeMenuMode, clear, clearAll, clearHeader, close, close, collapseItemActionView, expandItemActionView, findGroupIndex, findGroupIndex, findItem, findItemIndex, flagActionItems, getActionItems, getActionViewStatesKey, getContext, getExpandedItem, getHeaderIcon, getHeaderTitle, getHeaderView, getItem, getNonActionItems, getRootMenu, getVisibleItems, hasVisibleItems, isShortcutKey, isShortcutsVisible, onItemsChanged, performIdentifierAction, performItemAction, performItemAction, performShortcut, removeGroup, removeItem, removeItemAt, removeMenuPresenter, restoreActionViewStates, restorePresenterStates, saveActionViewStates, savePresenterStates, setCallback, setCurrentMenuInfo, setDefaultShowAsAction, setGroupCheckable, setGroupEnabled, setGroupVisible, setHeaderIconInt, setHeaderIconInt, setHeaderTitleInt, setHeaderTitleInt, setHeaderViewInt, setQwertyMode, setShortcutsVisible, size, startDispatchingItemsChanged, stopDispatchingItemsChanged
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clearHeader
add, add, add, add, addIntentOptions, addSubMenu, addSubMenu, addSubMenu, addSubMenu, clear, close, findItem, getItem, hasVisibleItems, isShortcutKey, performIdentifierAction, performShortcut, removeGroup, removeItem, setGroupCheckable, setGroupEnabled, setGroupVisible, setQwertyMode, size
public ContextMenuBuilder(Context context)
public ContextMenu setHeaderIcon(Drawable icon)
ContextMenu
Drawable
.setHeaderIcon
in interface ContextMenu
icon
- The Drawable
used for the icon.public ContextMenu setHeaderIcon(int iconRes)
ContextMenu
setHeaderIcon
in interface ContextMenu
iconRes
- The resource identifier used for the icon.public ContextMenu setHeaderTitle(CharSequence title)
ContextMenu
setHeaderTitle
in interface ContextMenu
title
- The character sequence used for the title.public ContextMenu setHeaderTitle(int titleRes)
ContextMenu
setHeaderTitle
in interface ContextMenu
titleRes
- The string resource identifier used for the title.public ContextMenu setHeaderView(View view)
ContextMenu
View
given in
view. This replaces the header title and icon (and those
replace this).setHeaderView
in interface ContextMenu
view
- The View
used for the header.public MenuDialogHelper showDialog(View originalView, IBinder token)
originalView
- Optional, the original view that triggered the
context menu.token
- Optional, the window token that should be set on the context
menu's window.MenuDialogHelper
for
dismissing it. Otherwise, null.public MenuPopupHelper showPopup(Context context, View originalView, float x, float y)