# ActionMode.Callback

Artifact: [androidx.appcompat:appcompat](https://developer.android.com/jetpack/androidx/releases/appcompat) [View Source](https://cs.android.com/search?q=file:androidx/appcompat/view/ActionMode.java+class:androidx.appcompat.view.ActionMode.Callback) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

*** ** * ** ***


```
public interface ActionMode.Callback
```

<br />

*** ** * ** ***

Callback interface for action modes. Supplied to `https://developer.android.com/reference/androidx/appcompat/app/AppCompatDelegate#startSupportActionMode(androidx.appcompat.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:

- `https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback#onCreateActionMode(androidx.appcompat.view.ActionMode,android.view.Menu)` once on initial creation
- `https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback#onPrepareActionMode(androidx.appcompat.view.ActionMode,android.view.Menu)` after creation and any time the `https://developer.android.com/reference/androidx/appcompat/view/ActionMode` is invalidated
- `https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback#onActionItemClicked(androidx.appcompat.view.ActionMode,android.view.MenuItem)` any time a contextual action button is clicked
- `https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback#onDestroyActionMode(androidx.appcompat.view.ActionMode)` when the action mode is closed

## Summary

| ### Public methods |
|---|---|
| `abstract boolean` | `https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback#onActionItemClicked(androidx.appcompat.view.ActionMode,android.view.MenuItem)(https://developer.android.com/reference/androidx/appcompat/view/ActionMode mode, https://developer.android.com/reference/android/view/MenuItem.html item)` Called to report a user click on an action button. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback#onCreateActionMode(androidx.appcompat.view.ActionMode,android.view.Menu)(https://developer.android.com/reference/androidx/appcompat/view/ActionMode mode, https://developer.android.com/reference/android/view/Menu.html menu)` Called when action mode is first created. |
| `abstract void` | `https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback#onDestroyActionMode(androidx.appcompat.view.ActionMode)(https://developer.android.com/reference/androidx/appcompat/view/ActionMode mode)` Called when an action mode is about to be exited and destroyed. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/appcompat/view/ActionMode.Callback#onPrepareActionMode(androidx.appcompat.view.ActionMode,android.view.Menu)(https://developer.android.com/reference/androidx/appcompat/view/ActionMode mode, 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 [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

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

Called to report a user click on an action button.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/view/ActionMode mode` | The current ActionMode |
| `https://developer.android.com/reference/android/view/MenuItem.html item` | The item that was clicked |

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

### onCreateActionMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

```
abstract 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.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/view/ActionMode mode` | ActionMode being created |
| `https://developer.android.com/reference/android/view/Menu.html menu` | Menu used to populate action buttons |

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

### onDestroyActionMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

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

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/view/ActionMode mode` | The current ActionMode being destroyed |

### onPrepareActionMode

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

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

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

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/appcompat/view/ActionMode mode` | ActionMode being prepared |
| `https://developer.android.com/reference/android/view/Menu.html menu` | Menu used to populate action buttons |

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