ActionMode
abstract class ActionMode
kotlin.Any | |
↳ | android.view.ActionMode |
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 classes | |
---|---|
abstract |
Callback interface for action modes. |
abstract |
Extension of |
Constants | |
---|---|
static Int |
Default value to hide the action mode for |
static Int |
The action mode is treated as a Floating Toolbar. |
static Int |
The action mode is treated as a Primary mode. |
Public constructors | |
---|---|
Public methods | |
---|---|
abstract Unit |
finish() Finish and close this action mode. |
abstract View! |
Returns the current custom view for this action mode. |
abstract Menu! |
getMenu() Returns the menu of actions that this action mode presents. |
abstract MenuInflater! |
Returns a |
abstract CharSequence! |
Returns the current subtitle of this action mode. |
open Any! |
getTag() Retrieve the tag object associated with this ActionMode. |
abstract CharSequence! |
getTitle() Returns the current title of this action mode. |
open Boolean | |
open Int |
getType() Returns the type for this action mode. |
open Unit |
Hide the action mode view from obstructing the content below for a short duration. |
abstract Unit |
Invalidate the action mode and refresh menu content. |
open Unit |
Invalidate the content rect associated to this ActionMode. |
open Boolean | |
open Unit |
onWindowFocusChanged(hasWindowFocus: Boolean) Called when the window containing the view that started this action mode gains or loses focus. |
abstract Unit |
setCustomView(view: View!) Set a custom view for this action mode. |
abstract Unit |
setSubtitle(subtitle: CharSequence!) Set the subtitle of the action mode. |
abstract Unit |
setSubtitle(resId: Int) Set the subtitle of the action mode. |
open Unit |
Set a tag object associated with this ActionMode. |
abstract Unit |
setTitle(title: CharSequence!) Set the title of the action mode. |
abstract Unit |
Set the title of the action mode. |
open Unit |
setTitleOptionalHint(titleOptional: Boolean) Set whether or not the title/subtitle display for this action mode is optional. |
open Unit |
Set a type for this action mode. |
Constants
DEFAULT_HIDE_DURATION
static val DEFAULT_HIDE_DURATION: Int
Default value to hide the action mode for ViewConfiguration#getDefaultActionModeHideDuration()
.
Value: -1
TYPE_FLOATING
static val TYPE_FLOATING: Int
The action mode is treated as a Floating Toolbar. Use with setType
.
Value: 1
TYPE_PRIMARY
static val TYPE_PRIMARY: Int
The action mode is treated as a Primary mode. This is the default. Use with setType
.
Value: 0
Public constructors
ActionMode
ActionMode()
Public methods
finish
abstract fun finish(): Unit
Finish and close this action mode. The action mode's ActionMode.Callback
will have its Callback#onDestroyActionMode(ActionMode)
method called.
getCustomView
abstract fun getCustomView(): View!
Returns the current custom view for this action mode.
Return | |
---|---|
View! |
The current custom view |
getMenu
abstract fun getMenu(): Menu!
Returns the menu of actions that this action mode presents.
Return | |
---|---|
Menu! |
The action mode's menu. |
getMenuInflater
abstract fun getMenuInflater(): MenuInflater!
Returns a MenuInflater
with the ActionMode's context.
getSubtitle
abstract fun getSubtitle(): CharSequence!
Returns the current subtitle of this action mode.
Return | |
---|---|
CharSequence! |
Subtitle text |
getTag
open 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.
Return | |
---|---|
Any! |
Tag associated with this ActionMode |
See Also
getTitle
abstract fun getTitle(): CharSequence!
Returns the current title of this action mode.
Return | |
---|---|
CharSequence! |
Title text |
getTitleOptionalHint
open fun getTitleOptionalHint(): Boolean
Return | |
---|---|
Boolean |
true if this action mode has been given a hint to consider the title/subtitle display to be optional. |
getType
open fun getType(): Int
Returns the type for this action mode.
Return | |
---|---|
Int |
One of TYPE_PRIMARY or TYPE_FLOATING . |
hide
open fun hide(duration: Long): Unit
Hide the action mode view from obstructing the content below for a short duration. This only makes sense for action modes that support dynamic positioning on the screen. If this method is called again before the hide duration expires, the later hide call will cancel the former and then take effect. NOTE that there is an internal limit to how long the mode can be hidden for. It's typically about a few seconds.
Parameters | |
---|---|
duration |
Long: The number of milliseconds to hide for. |
See Also
invalidate
abstract fun invalidate(): Unit
Invalidate the action mode and refresh menu content. The mode's ActionMode.Callback
will have its Callback#onPrepareActionMode(ActionMode, 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.
invalidateContentRect
open fun invalidateContentRect(): Unit
Invalidate the content rect associated to this ActionMode. This only makes sense for action modes that support dynamic positioning on the screen, and provides a more efficient way to reposition it without invalidating the whole action mode.
isTitleOptional
open fun isTitleOptional(): Boolean
Return | |
---|---|
Boolean |
true if this action mode considers the title and subtitle fields as optional. Optional titles may not be displayed to the user. |
onWindowFocusChanged
open fun onWindowFocusChanged(hasWindowFocus: Boolean): Unit
Called when the window containing the view that started this action mode gains or loses focus.
Parameters | |
---|---|
hasWindowFocus |
Boolean: True if the window containing the view that started this action mode now has focus, false otherwise. |
setCustomView
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 |
View!: Custom view to use in place of the title/subtitle. |
setSubtitle
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 |
CharSequence!: Subtitle string to set |
See Also
setSubtitle
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 |
Int: Resource ID of a string to set as the subtitle |
setTag
open 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 |
Any!: Tag to associate with this ActionMode |
See Also
setTitle
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 |
CharSequence!: Title string to set |
See Also
setTitle
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 |
Int: Resource ID of a string to set as the title |
setTitleOptionalHint
open 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 |
Boolean: true if the title only presents optional information. |
setType
open fun setType(type: Int): Unit
Set a type for this action mode. This will affect how the system renders the action mode if it has to.
Parameters | |
---|---|
type |
Int: One of TYPE_PRIMARY or TYPE_FLOATING . |