# ActionMode.Callback

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:appcompat-v7:28.0.0-alpha1  

# ActionMode.Callback

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public
static


interface
ActionMode.Callback
`  
`


`

|---------------------------------------------|
| android.support.v7.view.ActionMode.Callback |

<br />

*** ** * ** ***

Callback interface for action modes. Supplied to[startSupportActionMode(Callback)](https://developer.android.com/reference/android/support/v7/app/AppCompatDelegate#startSupportActionMode(android.support.v7.view.ActionMode.Callback))(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)](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onCreateActionMode(android.support.v7.view.ActionMode, android.view.Menu))once on initial creation
- [onPrepareActionMode(ActionMode, Menu)](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onPrepareActionMode(android.support.v7.view.ActionMode, android.view.Menu))after creation and any time the[ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode)is invalidated
- [onActionItemClicked(ActionMode, MenuItem)](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onActionItemClicked(android.support.v7.view.ActionMode, android.view.MenuItem))any time a contextual action button is clicked
- [onDestroyActionMode(ActionMode)](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onDestroyActionMode(android.support.v7.view.ActionMode))when the action mode is closed

<br />

## Summary

|                                                                                                                                                                                                                             ### Public methods                                                                                                                                                                                                                              ||
|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract boolean` | ` `[onActionItemClicked](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onActionItemClicked(android.support.v7.view.ActionMode, android.view.MenuItem))`(`[ActionMode](https://developer.android.com/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.             |
| ` abstract boolean` | ` `[onCreateActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onCreateActionMode(android.support.v7.view.ActionMode, android.view.Menu))`(`[ActionMode](https://developer.android.com/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.                                    |
| ` abstract void`    | ` `[onDestroyActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onDestroyActionMode(android.support.v7.view.ActionMode))`(`[ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode)` mode) ` Called when an action mode is about to be exited and destroyed.                                                                                                              |
| ` abstract boolean` | ` `[onPrepareActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onPrepareActionMode(android.support.v7.view.ActionMode, android.view.Menu))`(`[ActionMode](https://developer.android.com/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. |

## Public methods

### onActionItemClicked

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onActionItemClicked (ActionMode mode, 
                MenuItem item)
```

Called to report a user click on an action button.

<br />

|                      Parameters                      ||
|--------|----------------------------------------------|
| `mode` | `ActionMode`: The current ActionMode <br />  |
| `item` | `MenuItem`: The item that was clicked <br /> |

|                                                        Returns                                                        ||
|-----------|------------------------------------------------------------------------------------------------------------|
| `boolean` | true if this callback handled the event, false if the standard MenuItem invocation should continue. <br /> |

### onCreateActionMode

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onCreateActionMode (ActionMode mode, 
                Menu menu)
```

Called when action mode is first created. The menu supplied will be used to generate action buttons for the action mode.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `mode` | `ActionMode`: ActionMode being created <br />       |
| `menu` | `Menu`: Menu used to populate action buttons <br /> |

|                                                   Returns                                                   ||
|-----------|--------------------------------------------------------------------------------------------------|
| `boolean` | true if the action mode should be created, false if entering this mode should be aborted. <br /> |

### onDestroyActionMode

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onDestroyActionMode (ActionMode mode)
```

Called when an action mode is about to be exited and destroyed.

<br />

|                             Parameters                              ||
|--------|-------------------------------------------------------------|
| `mode` | `ActionMode`: The current ActionMode being destroyed <br /> |

### onPrepareActionMode

added in[version 22.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
boolean onPrepareActionMode (ActionMode mode, 
                Menu menu)
```

Called to refresh an action mode's action menu whenever it is invalidated.

<br />

|                         Parameters                          ||
|--------|-----------------------------------------------------|
| `mode` | `ActionMode`: ActionMode being prepared <br />      |
| `menu` | `Menu`: Menu used to populate action buttons <br /> |

|                                     Returns                                     ||
|-----------|----------------------------------------------------------------------|
| `boolean` | true if the menu or action mode was updated, false otherwise. <br /> |

-

  ## Interfaces

  - [ActionMode.Callback](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback)
  - [CollapsibleActionView](https://developer.android.com/reference/android/support/v7/view/CollapsibleActionView)
-

  ## Classes

  - [ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode)
  - [ContextThemeWrapper](https://developer.android.com/reference/android/support/v7/view/ContextThemeWrapper)