# ActionMode

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) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appcompat#1.1.0)

*** ** * ** ***


```
abstract class ActionMode
```

<br />

*** ** * ** ***

Represents a contextual mode of the user interface. Action modes can be used to provide alternative interaction modes and replace parts of the normal UI until finished. Examples of good action modes include text selection and contextual actions.

## Summary

| ### Nested types |
|---|
| `interface https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode.Callback` Callback interface for action modes. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#ActionMode()()` |

| ### Public functions |
|---|---|
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#finish()()` Finish and close this action mode. |
| `abstract https://developer.android.com/reference/android/view/View.html!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#getCustomView()()` Returns the current custom view for this action mode. |
| `abstract https://developer.android.com/reference/android/view/Menu.html!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#getMenu()()` Returns the menu of actions that this action mode presents. |
| `abstract https://developer.android.com/reference/android/view/MenuInflater.html!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#getMenuInflater()()` Returns a `https://developer.android.com/reference/android/view/MenuInflater.html` with the ActionMode's context. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#getSubtitle()()` Returns the current subtitle of this action mode. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#getTag()()` Retrieve the tag object associated with this ActionMode. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#getTitle()()` Returns the current title of this action mode. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#getTitleOptionalHint()()` |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#invalidate()()` Invalidate the action mode and refresh menu content. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#isTitleOptional()()` |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setCustomView(android.view.View)(view: https://developer.android.com/reference/android/view/View.html!)` Set a custom view for this action mode. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setSubtitle(int)(resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set the subtitle of the action mode. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setSubtitle(java.lang.CharSequence)(subtitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!)` Set the subtitle of the action mode. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setTag(java.lang.Object)(tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!)` Set a tag object associated with this ActionMode. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setTitle(int)(resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Set the title of the action mode. |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setTitle(java.lang.CharSequence)(title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!)` Set the title of the action mode. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setTitleOptionalHint(boolean)(titleOptional: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Set whether or not the title/subtitle display for this action mode is optional. |

## Public constructors

### ActionMode

Added in 1.1.0

```
ActionMode()
```

## Public functions

### finish

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

```
abstract fun finish(): Unit
```

Finish and close this action mode. The action mode's `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode.Callback` will have its `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode.Callback#onDestroyActionMode(androidx.appcompat.view.ActionMode)` method called.

### getCustomView

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

```
abstract fun getCustomView(): View!
```

Returns the current custom view for this action mode.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/View.html!` | The current custom view |

### getMenu

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

```
abstract fun getMenu(): Menu!
```

Returns the menu of actions that this action mode presents.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/view/Menu.html!` | The action mode's menu. |

### getMenuInflater

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

```
abstract fun getMenuInflater(): MenuInflater!
```

Returns a `https://developer.android.com/reference/android/view/MenuInflater.html` with the ActionMode's context.

### getSubtitle

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

```
abstract fun getSubtitle(): CharSequence!
```

Returns the current subtitle of this action mode.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | Subtitle text |

### getTag

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

```
fun getTag(): Any!
```

Retrieve the tag object associated with this ActionMode.

Like the tag available to views, this allows applications to associate arbitrary data with an ActionMode for later reference.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | Tag associated with this ActionMode |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setTag(java.lang.Object)` |   |

### getTitle

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

```
abstract fun getTitle(): CharSequence!
```

Returns the current title of this action mode.

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | Title text |

### getTitleOptionalHint

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

```
fun getTitleOptionalHint(): Boolean
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if this action mode has been given a hint to consider the title/subtitle display to be optional. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setTitleOptionalHint(boolean)` |   |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#isTitleOptional()` |   |

### invalidate

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

```
abstract fun invalidate(): Unit
```

Invalidate the action mode and refresh menu content. The mode's `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode.Callback` will have its `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode.Callback#onPrepareActionMode(androidx.appcompat.view.ActionMode,android.view.Menu)` method called. If it returns true the menu will be scanned for updated content and any relevant changes will be reflected to the user.

### isTitleOptional

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

```
fun isTitleOptional(): Boolean
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if this action mode considers the title and subtitle fields as optional. Optional titles may not be displayed to the user. |

### setCustomView

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

```
abstract fun setCustomView(view: View!): Unit
```

Set a custom view for this action mode. The custom view will take the place of the title and subtitle. Useful for things like search boxes.

| Parameters |
|---|---|
| `view: https://developer.android.com/reference/android/view/View.html!` | Custom view to use in place of the title/subtitle. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setTitle(java.lang.CharSequence)` |   |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setSubtitle(java.lang.CharSequence)` |   |

### setSubtitle

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

```
abstract fun setSubtitle(resId: Int): Unit
```

Set the subtitle of the action mode. This method will have no visible effect if a custom view has been set.

| Parameters |
|---|---|
| `resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Resource ID of a string to set as the subtitle |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setSubtitle(java.lang.CharSequence)` |   |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setCustomView(android.view.View)` |   |

### setSubtitle

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

```
abstract fun setSubtitle(subtitle: CharSequence!): Unit
```

Set the subtitle of the action mode. This method will have no visible effect if a custom view has been set.

| Parameters |
|---|---|
| `subtitle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | Subtitle string to set |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setSubtitle(int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setCustomView(android.view.View)` |   |

### setTag

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

```
fun setTag(tag: Any!): Unit
```

Set a tag object associated with this ActionMode.

Like the tag available to views, this allows applications to associate arbitrary data with an ActionMode for later reference.

| Parameters |
|---|---|
| `tag: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html!` | Tag to associate with this ActionMode |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#getTag()` |   |

### setTitle

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

```
abstract fun setTitle(resId: Int): Unit
```

Set the title of the action mode. This method will have no visible effect if a custom view has been set.

| Parameters |
|---|---|
| `resId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Resource ID of a string to set as the title |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setTitle(java.lang.CharSequence)` |   |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setCustomView(android.view.View)` |   |

### setTitle

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

```
abstract fun setTitle(title: CharSequence!): Unit
```

Set the title of the action mode. This method will have no visible effect if a custom view has been set.

| Parameters |
|---|---|
| `title: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-char-sequence/index.html!` | Title string to set |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setTitle(int)` |   |
| `https://developer.android.com/reference/kotlin/androidx/appcompat/view/ActionMode#setCustomView(android.view.View)` |   |

### setTitleOptionalHint

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

```
fun setTitleOptionalHint(titleOptional: Boolean): Unit
```

Set whether or not the title/subtitle display for this action mode is optional.

In many cases the supplied title for an action mode is merely meant to add context and is not strictly required for the action mode to be useful. If the title is optional, the system may choose to hide the title entirely rather than truncate it due to a lack of available space.

Note that this is merely a hint; the underlying implementation may choose to ignore this setting under some circumstances.

| Parameters |
|---|---|
| `titleOptional: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if the title only presents optional information. |