Package icyllis.modernui.view
Interface ActionMode.Callback
- All Known Subinterfaces:
AbsListView.MultiChoiceModeListener
- Enclosing class:
ActionMode
public static interface ActionMode.Callback
Callback interface for action modes. Supplied to
View.startActionMode(Callback)
, a Callback
configures and handles events raised by a user's interaction with an action mode.
An action mode's lifecycle is as follows:
onCreateActionMode(ActionMode, Menu)
once on initial creationonPrepareActionMode(ActionMode, Menu)
after creation and any time theActionMode
is invalidatedonActionItemClicked(ActionMode, MenuItem)
any time a contextual action button is clickedonDestroyActionMode(ActionMode)
when the action mode is closed
-
Method Summary
Modifier and TypeMethodDescriptionboolean
onActionItemClicked
(ActionMode mode, MenuItem item) Called to report a user click on an action button.boolean
onCreateActionMode
(ActionMode mode, Menu menu) Called when action mode is first created.void
Called when an action mode is about to be exited and destroyed.default void
onGetContentRect
(ActionMode mode, View view, Rect outRect) Extension ofActionMode.Callback
to provide content rect information.boolean
onPrepareActionMode
(ActionMode mode, Menu menu) Called to refresh an action mode's action menu whenever it is invalidated.
-
Method Details
-
onCreateActionMode
Called when action mode is first created. The menu supplied will be used to generate action buttons for the action mode.- Parameters:
mode
- ActionMode being createdmenu
- Menu used to populate action buttons- Returns:
- true if the action mode should be created, false if entering this mode should be aborted.
-
onPrepareActionMode
Called to refresh an action mode's action menu whenever it is invalidated.- Parameters:
mode
- ActionMode being preparedmenu
- Menu used to populate action buttons- Returns:
- true if the menu or action mode was updated, false otherwise.
-
onActionItemClicked
Called to report a user click on an action button.- Parameters:
mode
- The current ActionModeitem
- The item that was clicked- Returns:
- true if this callback handled the event, false if the standard MenuItem invocation should continue.
-
onDestroyActionMode
Called when an action mode is about to be exited and destroyed.- Parameters:
mode
- The current ActionMode being destroyed
-
onGetContentRect
Extension ofActionMode.Callback
to provide content rect information. This is required for ActionModes with dynamic positioning such as the ones with typeActionMode.TYPE_FLOATING
to ensure the positioning doesn't obscure app content. Called when an ActionMode needs to be positioned on screen, potentially occluding view content. Note this may be called on a per-frame basis.- Parameters:
mode
- The ActionMode that requires positioning.view
- The View that originated the ActionMode, in whose coordinates the Rect should be provided.outRect
- The Rect to be populated with the content position. Use this to specify where the content in your app lives within the given view. This will be used to avoid occluding the given content Rect with the created ActionMode.
-