Stay organized with collections
Save and categorize content based on your preferences.
added in version 22.1.0
belongs to Maven artifact com.android.support:appcompat-v7:28.0.0-alpha1
ActionMode.Callback
public
static
interface
ActionMode.Callback
android.support.v7.view.ActionMode.Callback
Callback interface for action modes. Supplied to
startSupportActionMode(Callback) (Callback)},
a Callback configures and handles events raised by a user's interaction with an action mode.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# ActionMode.Callback\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \nbelongs to Maven artifact com.android.support:appcompat-v7:28.0.0-alpha1 \n\nActionMode.Callback\n===================\n\n| This package is part of the Android [support library](/topic/libraries/support-library) which is no longer maintained. The support library has been superseded by [AndroidX](/jetpack/androidx) which is part of [Jetpack](/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider [migrating](/jetpack/androidx/migrate) existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library [class\n| mappings](/jetpack/androidx/migrate/class-mappings).\n\n\n`\npublic\nstatic\n\n\ninterface\nActionMode.Callback\n`\n\n\n`\n\n\n`\n\n|---------------------------------------------|\n| android.support.v7.view.ActionMode.Callback |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nCallback interface for action modes. Supplied to\n[startSupportActionMode(Callback)](/reference/android/support/v7/app/AppCompatDelegate#startSupportActionMode(android.support.v7.view.ActionMode.Callback)) (Callback)},\na Callback configures and handles events raised by a user's interaction with an action mode.\n\nAn action mode's lifecycle is as follows:\n\n- [onCreateActionMode(ActionMode, Menu)](/reference/android/support/v7/view/ActionMode.Callback#onCreateActionMode(android.support.v7.view.ActionMode, android.view.Menu)) once on initial creation\n- [onPrepareActionMode(ActionMode, Menu)](/reference/android/support/v7/view/ActionMode.Callback#onPrepareActionMode(android.support.v7.view.ActionMode, android.view.Menu)) after creation and any time the [ActionMode](/reference/android/support/v7/view/ActionMode) is invalidated\n- [onActionItemClicked(ActionMode, MenuItem)](/reference/android/support/v7/view/ActionMode.Callback#onActionItemClicked(android.support.v7.view.ActionMode, android.view.MenuItem)) any time a contextual action button is clicked\n- [onDestroyActionMode(ActionMode)](/reference/android/support/v7/view/ActionMode.Callback#onDestroyActionMode(android.support.v7.view.ActionMode)) when the action mode is closed\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Public methods ||\n|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` abstract boolean` | ` `[onActionItemClicked](/reference/android/support/v7/view/ActionMode.Callback#onActionItemClicked(android.support.v7.view.ActionMode, android.view.MenuItem))`(`[ActionMode](/reference/android/support/v7/view/ActionMode)` mode, `[MenuItem](https://developer.android.com/reference/android/view/MenuItem.html)` item) ` Called to report a user click on an action button. |\n| ` abstract boolean` | ` `[onCreateActionMode](/reference/android/support/v7/view/ActionMode.Callback#onCreateActionMode(android.support.v7.view.ActionMode, android.view.Menu))`(`[ActionMode](/reference/android/support/v7/view/ActionMode)` mode, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` menu) ` Called when action mode is first created. |\n| ` abstract void` | ` `[onDestroyActionMode](/reference/android/support/v7/view/ActionMode.Callback#onDestroyActionMode(android.support.v7.view.ActionMode))`(`[ActionMode](/reference/android/support/v7/view/ActionMode)` mode) ` Called when an action mode is about to be exited and destroyed. |\n| ` abstract boolean` | ` `[onPrepareActionMode](/reference/android/support/v7/view/ActionMode.Callback#onPrepareActionMode(android.support.v7.view.ActionMode, android.view.Menu))`(`[ActionMode](/reference/android/support/v7/view/ActionMode)` mode, `[Menu](https://developer.android.com/reference/android/view/Menu.html)` menu) ` Called to refresh an action mode's action menu whenever it is invalidated. |\n\nPublic methods\n--------------\n\n### onActionItemClicked\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nboolean onActionItemClicked (ActionMode mode, \n MenuItem item)\n```\n\nCalled to report a user click on an action button.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|----------------------------------------------|\n| `mode` | `ActionMode`: The current ActionMode \u003cbr /\u003e |\n| `item` | `MenuItem`: The item that was clicked \u003cbr /\u003e |\n\n| Returns ||\n|-----------|------------------------------------------------------------------------------------------------------------|\n| `boolean` | true if this callback handled the event, false if the standard MenuItem invocation should continue. \u003cbr /\u003e |\n\n### onCreateActionMode\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nboolean onCreateActionMode (ActionMode mode, \n Menu menu)\n```\n\nCalled when action mode is first created. The menu supplied will be used to\ngenerate action buttons for the action mode.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|-----------------------------------------------------|\n| `mode` | `ActionMode`: ActionMode being created \u003cbr /\u003e |\n| `menu` | `Menu`: Menu used to populate action buttons \u003cbr /\u003e |\n\n| Returns ||\n|-----------|--------------------------------------------------------------------------------------------------|\n| `boolean` | true if the action mode should be created, false if entering this mode should be aborted. \u003cbr /\u003e |\n\n### onDestroyActionMode\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nvoid onDestroyActionMode (ActionMode mode)\n```\n\nCalled when an action mode is about to be exited and destroyed.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|-------------------------------------------------------------|\n| `mode` | `ActionMode`: The current ActionMode being destroyed \u003cbr /\u003e |\n\n### onPrepareActionMode\n\nadded in [version 22.1.0](/topic/libraries/support-library/revisions) \n\n```\nboolean onPrepareActionMode (ActionMode mode, \n Menu menu)\n```\n\nCalled to refresh an action mode's action menu whenever it is invalidated.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|-----------------------------------------------------|\n| `mode` | `ActionMode`: ActionMode being prepared \u003cbr /\u003e |\n| `menu` | `Menu`: Menu used to populate action buttons \u003cbr /\u003e |\n\n| Returns ||\n|-----------|----------------------------------------------------------------------|\n| `boolean` | true if the menu or action mode was updated, false otherwise. \u003cbr /\u003e |\n\n-\n\n Interfaces\n ----------\n\n - [ActionMode.Callback](/reference/android/support/v7/view/ActionMode.Callback)\n - [CollapsibleActionView](/reference/android/support/v7/view/CollapsibleActionView)\n-\n\n Classes\n -------\n\n - [ActionMode](/reference/android/support/v7/view/ActionMode)\n - [ContextThemeWrapper](/reference/android/support/v7/view/ContextThemeWrapper)"]]