public abstract class MenuPopup extends Object implements ShowableListMenu, MenuPresenter, AdapterView.OnItemClickListener
MenuPresenter.Callback
Constructor and Description |
---|
MenuPopup() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addMenu(MenuBuilder menu)
Adds the given menu to the popup, if it is capable of displaying submenus within itself.
|
boolean |
collapseItemActionView(MenuBuilder menu,
MenuItemImpl item)
Called when a menu item with a collapsable action view should collapse its action view.
|
boolean |
expandItemActionView(MenuBuilder menu,
MenuItemImpl item)
Called when a menu item with a collapsable action view should expand its action view.
|
Rect |
getEpicenterBounds() |
int |
getId()
Returns an ID for determining how to save/restore instance state.
|
MenuView |
getMenuView(ViewGroup root)
Retrieve a MenuView to display the menu specified in
MenuPresenter.initForMenu(Context, MenuBuilder) . |
void |
initForMenu(Context context,
MenuBuilder menu)
Initializes this presenter for the given context and menu.
|
protected static int |
measureIndividualMenuWidth(ListAdapter adapter,
ViewGroup parent,
Context context,
int maxAllowedWidth)
Measures the width of the given menu view.
|
void |
onItemClick(AdapterView<?> parent,
View view,
int position,
long id)
Callback method to be invoked when an item in this AdapterView has
been clicked.
|
abstract void |
setAnchorView(View anchor) |
void |
setEpicenterBounds(Rect bounds)
Specifies the anchor-relative bounds of the popup's transition
epicenter.
|
abstract void |
setForceShowIcon(boolean forceShow) |
abstract void |
setGravity(int dropDownGravity) |
abstract void |
setHorizontalOffset(int x) |
abstract void |
setOnDismissListener(PopupWindow.OnDismissListener listener)
Set a listener to receive a callback when the popup is dismissed.
|
abstract void |
setShowTitle(boolean showTitle)
Set whether a title entry should be shown in the popup menu (if a title exists for the
menu).
|
abstract void |
setVerticalOffset(int y) |
protected static boolean |
shouldPreserveIconSpacing(MenuBuilder menu)
Returns whether icon spacing needs to be preserved for the given menu, based on whether any
of its items contains an icon.
|
protected static MenuAdapter |
toMenuAdapter(ListAdapter adapter)
Converts the given ListAdapter originating from a menu, to a MenuAdapter, accounting for
the possibility of the parameter adapter actually wrapping the MenuAdapter.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
dismiss, getListView, isShowing, show
flagActionItems, onCloseMenu, onRestoreInstanceState, onSaveInstanceState, onSubMenuSelected, setCallback, updateMenuView
public abstract void setForceShowIcon(boolean forceShow)
public abstract void addMenu(MenuBuilder menu)
menu
- public abstract void setGravity(int dropDownGravity)
public abstract void setAnchorView(View anchor)
public abstract void setHorizontalOffset(int x)
public abstract void setVerticalOffset(int y)
public void setEpicenterBounds(Rect bounds)
bounds
- anchor-relative boundspublic Rect getEpicenterBounds()
public abstract void setShowTitle(boolean showTitle)
showTitle
- public abstract void setOnDismissListener(PopupWindow.OnDismissListener listener)
listener
- Listener that will be notified when the popup is dismissed.public void initForMenu(Context context, MenuBuilder menu)
MenuPresenter
This method is called by MenuBuilder when a presenter is added. See
MenuBuilder.addMenuPresenter(MenuPresenter)
.
initForMenu
in interface MenuPresenter
context
- the context for this presenter; used for view creation
and resource management, must be non-null
menu
- the menu to host, or null
to clear the hosted menupublic MenuView getMenuView(ViewGroup root)
MenuPresenter
MenuPresenter.initForMenu(Context, MenuBuilder)
.getMenuView
in interface MenuPresenter
root
- Intended parent of the MenuView.public boolean expandItemActionView(MenuBuilder menu, MenuItemImpl item)
MenuPresenter
expandItemActionView
in interface MenuPresenter
menu
- Menu containing the item to be expandeditem
- Item to be expandedpublic boolean collapseItemActionView(MenuBuilder menu, MenuItemImpl item)
MenuPresenter
collapseItemActionView
in interface MenuPresenter
menu
- Menu containing the item to be collapseditem
- Item to be collapsedpublic int getId()
MenuPresenter
getId
in interface MenuPresenter
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
AdapterView.OnItemClickListener
Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.
onItemClick
in interface AdapterView.OnItemClickListener
parent
- The AdapterView where the click happened.view
- The view within the AdapterView that was clicked (this
will be a view provided by the adapter)position
- The position of the view in the adapter.id
- The row id of the item that was clicked.protected static int measureIndividualMenuWidth(ListAdapter adapter, ViewGroup parent, Context context, int maxAllowedWidth)
view
- The view to measure.protected static MenuAdapter toMenuAdapter(ListAdapter adapter)
adapter
- protected static boolean shouldPreserveIconSpacing(MenuBuilder menu)
menu
-