FileDocCategorySizeDatePackage
MenuPresenter.javaAPI DocAndroid 5.1 API5459Thu Mar 12 22:22:10 GMT 2015com.android.internal.view.menu

MenuPresenter

public interface MenuPresenter
A MenuPresenter is responsible for building views for a Menu object. It takes over some responsibility from the old style monolithic MenuBuilder class.

Fields Summary
Constructors Summary
Methods Summary
public booleancollapseItemActionView(MenuBuilder menu, MenuItemImpl item)
Called when a menu item with a collapsable action view should collapse its action view.

param
menu Menu containing the item to be collapsed
param
item Item to be collapsed
return
true if this presenter collapsed the action view, false otherwise.

public booleanexpandItemActionView(MenuBuilder menu, MenuItemImpl item)
Called when a menu item with a collapsable action view should expand its action view.

param
menu Menu containing the item to be expanded
param
item Item to be expanded
return
true if this presenter expanded the action view, false otherwise.

public booleanflagActionItems()
Called by Menu implementations to flag items that will be shown as actions.

return
true if this presenter changed the action status of any items.

public intgetId()
Returns an ID for determining how to save/restore instance state.

return
a valid ID value.

public MenuViewgetMenuView(android.view.ViewGroup root)
Retrieve a MenuView to display the menu specified in {@link #initForMenu(Context, MenuBuilder)}.

param
root Intended parent of the MenuView.
return
A freshly created MenuView.

public voidinitForMenu(android.content.Context context, MenuBuilder menu)
Initialize this presenter for the given context and menu. This method is called by MenuBuilder when a presenter is added. See {@link MenuBuilder#addMenuPresenter(MenuPresenter)}

param
context Context for this presenter; used for view creation and resource management
param
menu Menu to host

public voidonCloseMenu(MenuBuilder menu, boolean allMenusAreClosing)
Called by Menu implementations to indicate that a menu or submenu is closing. Presenter implementations should close the representation of the menu indicated as necessary and notify a registered callback.

param
menu Menu or submenu that is closing.
param
allMenusAreClosing True if all associated menus are closing.

public voidonRestoreInstanceState(android.os.Parcelable state)
Supplies the previously saved instance state to be restored.

param
state The previously saved instance state

public android.os.ParcelableonSaveInstanceState()
Returns a Parcelable describing the current state of the presenter. It will be passed to the {@link #onRestoreInstanceState(Parcelable)} method of the presenter sharing the same ID later.

return
The saved instance state

public booleanonSubMenuSelected(SubMenuBuilder subMenu)
Called by Menu implementations to indicate that a submenu item has been selected. An active Callback should be notified, and if applicable the presenter should present the submenu.

param
subMenu SubMenu being opened
return
true if the the event was handled, false otherwise.

public voidsetCallback(com.android.internal.view.menu.MenuPresenter$Callback cb)
Set a callback object that will be notified of menu events related to this specific presentation.

param
cb Callback that will be notified of future events

public voidupdateMenuView(boolean cleared)
Update the menu UI in response to a change. Called by MenuBuilder during the normal course of operation.

param
cleared true if the menu was entirely cleared