public abstract class ActionMode extends Object
For information about how to provide contextual actions with ActionMode
,
read the Menus
developer guide.
Modifier and Type | Class and Description |
---|---|
static interface |
ActionMode.Callback
Callback interface for action modes.
|
static class |
ActionMode.Callback2
Extension of
ActionMode.Callback to provide content rect information. |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_HIDE_DURATION
Default value to hide the action mode for
ViewConfiguration.getDefaultActionModeHideDuration() . |
static int |
TYPE_FLOATING
The action mode is treated as a Floating Toolbar.
|
static int |
TYPE_PRIMARY
The action mode is treated as a Primary mode.
|
Constructor and Description |
---|
ActionMode() |
Modifier and Type | Method and Description |
---|---|
abstract void |
finish()
Finish and close this action mode.
|
abstract View |
getCustomView()
Returns the current custom view for this action mode.
|
abstract Menu |
getMenu()
Returns the menu of actions that this action mode presents.
|
abstract MenuInflater |
getMenuInflater()
Returns a
MenuInflater with the ActionMode's context. |
abstract CharSequence |
getSubtitle()
Returns the current subtitle of this action mode.
|
Object |
getTag()
Retrieve the tag object associated with this ActionMode.
|
abstract CharSequence |
getTitle()
Returns the current title of this action mode.
|
boolean |
getTitleOptionalHint() |
int |
getType()
Returns the type for this action mode.
|
void |
hide(long duration)
Hide the action mode view from obstructing the content below for a short duration.
|
abstract void |
invalidate()
Invalidate the action mode and refresh menu content.
|
void |
invalidateContentRect()
Invalidate the content rect associated to this ActionMode.
|
boolean |
isTitleOptional() |
boolean |
isUiFocusable()
Returns whether the UI presenting this action mode can take focus or not.
|
void |
onWindowFocusChanged(boolean hasWindowFocus)
Called when the window containing the view that started this action mode gains or loses
focus.
|
abstract void |
setCustomView(View view)
Set a custom view for this action mode.
|
abstract void |
setSubtitle(CharSequence subtitle)
Set the subtitle of the action mode.
|
abstract void |
setSubtitle(int resId)
Set the subtitle of the action mode.
|
void |
setTag(Object tag)
Set a tag object associated with this ActionMode.
|
abstract void |
setTitle(CharSequence title)
Set the title of the action mode.
|
abstract void |
setTitle(int resId)
Set the title of the action mode.
|
void |
setTitleOptionalHint(boolean titleOptional)
Set whether or not the title/subtitle display for this action mode
is optional.
|
void |
setType(int type)
Set a type for this action mode.
|
public static final int TYPE_PRIMARY
setType(int)
.public static final int TYPE_FLOATING
setType(int)
.public static final int DEFAULT_HIDE_DURATION
ViewConfiguration.getDefaultActionModeHideDuration()
.public void setTag(Object tag)
Like the tag available to views, this allows applications to associate arbitrary data with an ActionMode for later reference.
tag
- Tag to associate with this ActionModegetTag()
public Object getTag()
Like the tag available to views, this allows applications to associate arbitrary data with an ActionMode for later reference.
setTag(Object)
public abstract void setTitle(CharSequence title)
title
- Title string to setsetTitle(int)
,
setCustomView(View)
public abstract void setTitle(@StringRes int resId)
resId
- Resource ID of a string to set as the titlesetTitle(CharSequence)
,
setCustomView(View)
public abstract void setSubtitle(CharSequence subtitle)
subtitle
- Subtitle string to setsetSubtitle(int)
,
setCustomView(View)
public abstract void setSubtitle(@StringRes int resId)
resId
- Resource ID of a string to set as the subtitlesetSubtitle(CharSequence)
,
setCustomView(View)
public void setTitleOptionalHint(boolean titleOptional)
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.
titleOptional
- true if the title only presents optional information.public boolean getTitleOptionalHint()
setTitleOptionalHint(boolean)
,
isTitleOptional()
public boolean isTitleOptional()
public abstract void setCustomView(View view)
view
- Custom view to use in place of the title/subtitle.setTitle(CharSequence)
,
setSubtitle(CharSequence)
public void setType(int type)
type
- One of TYPE_PRIMARY
or TYPE_FLOATING
.public int getType()
TYPE_PRIMARY
or TYPE_FLOATING
.public abstract void invalidate()
ActionMode.Callback
will have its
ActionMode.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.public void invalidateContentRect()
.
public void hide(long duration)
duration
- The number of milliseconds to hide for.DEFAULT_HIDE_DURATION
public abstract void finish()
ActionMode.Callback
will
have its ActionMode.Callback.onDestroyActionMode(ActionMode)
method called.public abstract Menu getMenu()
public abstract CharSequence getTitle()
public abstract CharSequence getSubtitle()
public abstract View getCustomView()
public abstract MenuInflater getMenuInflater()
MenuInflater
with the ActionMode's context.public void onWindowFocusChanged(boolean hasWindowFocus)
hasWindowFocus
- True if the window containing the view that started this action mode
now has focus, false otherwise.public boolean isUiFocusable()