# ActionMode

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  
Summary:[Nested Classes](https://developer.android.com/reference/android/support/v7/view/ActionMode#nestedclasses)\|[Ctors](https://developer.android.com/reference/android/support/v7/view/ActionMode#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v7/view/ActionMode#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/view/ActionMode#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/view/ActionMode#)  

# ActionMode

| 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


abstract
class
ActionMode
`  
`

extends Object


``


`

|---|------------------------------------|
| java.lang.Object                      ||
| ↳ | android.support.v7.view.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.  

### Developer Guides

For information about how to provide contextual actions with`ActionMode`, read the[Menus](https://developer.android.com/guide/topics/ui/menus#context-menu)developer guide.

<br />

## Summary

|                                                                      ### Nested classes                                                                       ||
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------|
| ` interface` | [ActionMode.Callback](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback) Callback interface for action modes. |

|                                             ### Public constructors                                              ||
|---------------------------------------------------------------------------------------------------------------|---|
| ` `[ActionMode](https://developer.android.com/reference/android/support/v7/view/ActionMode#ActionMode())`() ` |

|                                                                                                                                                                      ### Public methods                                                                                                                                                                       ||
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract void`                                                                                   | ` `[finish](https://developer.android.com/reference/android/support/v7/view/ActionMode#finish())`() ` Finish and close this action mode.                                                                                                                  |
| ` abstract `[View](https://developer.android.com/reference/android/view/View.html)                 | ` `[getCustomView](https://developer.android.com/reference/android/support/v7/view/ActionMode#getCustomView())`() ` Returns the current custom view for this action mode.                                                                                 |
| ` abstract `[Menu](https://developer.android.com/reference/android/view/Menu.html)                 | ` `[getMenu](https://developer.android.com/reference/android/support/v7/view/ActionMode#getMenu())`() ` Returns the menu of actions that this action mode presents.                                                                                       |
| ` abstract `[MenuInflater](https://developer.android.com/reference/android/view/MenuInflater.html) | ` `[getMenuInflater](https://developer.android.com/reference/android/support/v7/view/ActionMode#getMenuInflater())`() ` Returns a[MenuInflater](https://developer.android.com/reference/android/view/MenuInflater.html)with the ActionMode's context.     |
| ` abstract CharSequence`                                                                           | ` `[getSubtitle](https://developer.android.com/reference/android/support/v7/view/ActionMode#getSubtitle())`() ` Returns the current subtitle of this action mode.                                                                                         |
| ` Object`                                                                                          | ` `[getTag](https://developer.android.com/reference/android/support/v7/view/ActionMode#getTag())`() ` Retrieve the tag object associated with this ActionMode.                                                                                            |
| ` abstract CharSequence`                                                                           | ` `[getTitle](https://developer.android.com/reference/android/support/v7/view/ActionMode#getTitle())`() ` Returns the current title of this action mode.                                                                                                  |
| ` boolean`                                                                                         | ` `[getTitleOptionalHint](https://developer.android.com/reference/android/support/v7/view/ActionMode#getTitleOptionalHint())`() `                                                                                                                         |
| ` abstract void`                                                                                   | ` `[invalidate](https://developer.android.com/reference/android/support/v7/view/ActionMode#invalidate())`() ` Invalidate the action mode and refresh menu content.                                                                                        |
| ` boolean`                                                                                         | ` `[isTitleOptional](https://developer.android.com/reference/android/support/v7/view/ActionMode#isTitleOptional())`() `                                                                                                                                   |
| ` abstract void`                                                                                   | ` `[setCustomView](https://developer.android.com/reference/android/support/v7/view/ActionMode#setCustomView(android.view.View))`(`[View](https://developer.android.com/reference/android/view/View.html)` view) ` Set a custom view for this action mode. |
| ` abstract void`                                                                                   | ` `[setSubtitle](https://developer.android.com/reference/android/support/v7/view/ActionMode#setSubtitle(java.lang.CharSequence))`(CharSequence subtitle) ` Set the subtitle of the action mode.                                                           |
| ` abstract void`                                                                                   | ` `[setSubtitle](https://developer.android.com/reference/android/support/v7/view/ActionMode#setSubtitle(int))`(int resId) ` Set the subtitle of the action mode.                                                                                          |
| ` void`                                                                                            | ` `[setTag](https://developer.android.com/reference/android/support/v7/view/ActionMode#setTag(java.lang.Object))`(Object tag) ` Set a tag object associated with this ActionMode.                                                                         |
| ` abstract void`                                                                                   | ` `[setTitle](https://developer.android.com/reference/android/support/v7/view/ActionMode#setTitle(java.lang.CharSequence))`(CharSequence title) ` Set the title of the action mode.                                                                       |
| ` abstract void`                                                                                   | ` `[setTitle](https://developer.android.com/reference/android/support/v7/view/ActionMode#setTitle(int))`(int resId) ` Set the title of the action mode.                                                                                                   |
| ` void`                                                                                            | ` `[setTitleOptionalHint](https://developer.android.com/reference/android/support/v7/view/ActionMode#setTitleOptionalHint(boolean))`(boolean titleOptional) ` Set whether or not the title/subtitle display for this action mode is optional.             |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/view/ActionMode#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||

## Public constructors

### ActionMode

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

```
ActionMode ()
```

<br />

<br />

## Public methods

### finish

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

```
void finish ()
```

Finish and close this action mode. The action mode's[ActionMode.Callback](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback)will have its[onDestroyActionMode(ActionMode)](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onDestroyActionMode(android.support.v7.view.ActionMode))method called.

<br />

### getCustomView

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

```
View getCustomView ()
```

Returns the current custom view for this action mode.

<br />

|                                                Returns                                                 ||
|------------------------------------------------------------------------|--------------------------------|
| [View](https://developer.android.com/reference/android/view/View.html) | The current custom view <br /> |

### getMenu

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

```
Menu getMenu ()
```

Returns the menu of actions that this action mode presents.

<br />

|                                                Returns                                                 ||
|------------------------------------------------------------------------|--------------------------------|
| [Menu](https://developer.android.com/reference/android/view/Menu.html) | The action mode's menu. <br /> |

### getMenuInflater

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

```
MenuInflater getMenuInflater ()
```

Returns a[MenuInflater](https://developer.android.com/reference/android/view/MenuInflater.html)with the ActionMode's context.

<br />

|                                            Returns                                             ||
|----------------------------------------------------------------------------------------|--------|
| [MenuInflater](https://developer.android.com/reference/android/view/MenuInflater.html) | <br /> |

### getSubtitle

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

```
CharSequence getSubtitle ()
```

Returns the current subtitle of this action mode.

<br />

|               Returns                ||
|----------------|----------------------|
| `CharSequence` | Subtitle text <br /> |

### getTag

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

```
Object getTag ()
```

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.

<br />

|                       Returns                        ||
|----------|--------------------------------------------|
| `Object` | Tag associated with this ActionMode <br /> |

**See also:**

- [setTag(Object)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setTag(java.lang.Object))  

### getTitle

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

```
CharSequence getTitle ()
```

Returns the current title of this action mode.

<br />

|              Returns              ||
|----------------|-------------------|
| `CharSequence` | Title text <br /> |

### getTitleOptionalHint

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

```
boolean getTitleOptionalHint ()
```

<br />

<br />

|                                                         Returns                                                         ||
|-----------|--------------------------------------------------------------------------------------------------------------|
| `boolean` | true if this action mode has been given a hint to consider the title/subtitle display to be optional. <br /> |

**See also:**

- [setTitleOptionalHint(boolean)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setTitleOptionalHint(boolean))
- [isTitleOptional()](https://developer.android.com/reference/android/support/v7/view/ActionMode#isTitleOptional())  

### invalidate

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

```
void invalidate ()
```

Invalidate the action mode and refresh menu content. The mode's[ActionMode.Callback](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback)will have its[onPrepareActionMode(ActionMode, Menu)](https://developer.android.com/reference/android/support/v7/view/ActionMode.Callback#onPrepareActionMode(android.support.v7.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.

<br />

### isTitleOptional

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

```
boolean isTitleOptional ()
```

<br />

<br />

|                                                                      Returns                                                                      ||
|-----------|----------------------------------------------------------------------------------------------------------------------------------------|
| `boolean` | true if this action mode considers the title and subtitle fields as optional. Optional titles may not be displayed to the user. <br /> |

### setCustomView

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

```
void setCustomView (View view)
```

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.

<br />

|                                Parameters                                 ||
|--------|-------------------------------------------------------------------|
| `view` | `View`: Custom view to use in place of the title/subtitle. <br /> |

**See also:**

- [setTitle(CharSequence)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setTitle(java.lang.CharSequence))
- [setSubtitle(CharSequence)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setSubtitle(java.lang.CharSequence))  

### setSubtitle

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

```
void setSubtitle (CharSequence subtitle)
```

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

<br />

|                        Parameters                         ||
|------------|-----------------------------------------------|
| `subtitle` | `CharSequence`: Subtitle string to set <br /> |

**See also:**

- [setSubtitle(int)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setSubtitle(int))
- [setCustomView(View)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setCustomView(android.view.View))  

### setSubtitle

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

```
void setSubtitle (int resId)
```

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

<br />

|                              Parameters                               ||
|---------|--------------------------------------------------------------|
| `resId` | `int`: Resource ID of a string to set as the subtitle <br /> |

**See also:**

- [setSubtitle(CharSequence)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setSubtitle(java.lang.CharSequence))
- [setCustomView(View)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setCustomView(android.view.View))  

### setTag

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

```
void setTag (Object tag)
```

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.

<br />

|                          Parameters                           ||
|-------|--------------------------------------------------------|
| `tag` | `Object`: Tag to associate with this ActionMode <br /> |

**See also:**

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

### setTitle

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

```
void setTitle (CharSequence title)
```

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

<br />

|                     Parameters                      ||
|---------|--------------------------------------------|
| `title` | `CharSequence`: Title string to set <br /> |

**See also:**

- [setTitle(int)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setTitle(int))
- [setCustomView(View)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setCustomView(android.view.View))  

### setTitle

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

```
void setTitle (int resId)
```

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

<br />

|                             Parameters                             ||
|---------|-----------------------------------------------------------|
| `resId` | `int`: Resource ID of a string to set as the title <br /> |

**See also:**

- [setTitle(CharSequence)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setTitle(java.lang.CharSequence))
- [setCustomView(View)](https://developer.android.com/reference/android/support/v7/view/ActionMode#setCustomView(android.view.View))  

### setTitleOptionalHint

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

```
void setTitleOptionalHint (boolean titleOptional)
```

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.

<br />

<br />

|                                        Parameters                                        ||
|-----------------|-------------------------------------------------------------------------|
| `titleOptional` | `boolean`: true if the title only presents optional information. <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)