FileDocCategorySizeDatePackage
ActionMode.javaAPI DocAndroid 5.1 API9208Thu Mar 12 22:22:10 GMT 2015android.view

ActionMode

public abstract class ActionMode extends Object
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 {@code ActionMode}, read the Menus developer guide.

Fields Summary
private Object
mTag
private boolean
mTitleOptionalHint
Constructors Summary
Methods Summary
public abstract voidfinish()
Finish and close this action mode. The action mode's {@link ActionMode.Callback} will have its {@link Callback#onDestroyActionMode(ActionMode)} method called.

public abstract ViewgetCustomView()
Returns the current custom view for this action mode.

return
The current custom view

public abstract MenugetMenu()
Returns the menu of actions that this action mode presents.

return
The action mode's menu.

public abstract MenuInflatergetMenuInflater()
Returns a {@link MenuInflater} with the ActionMode's context.

public abstract java.lang.CharSequencegetSubtitle()
Returns the current subtitle of this action mode.

return
Subtitle text

public java.lang.ObjectgetTag()
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
Tag associated with this ActionMode
see
#setTag(Object)

        return mTag;
    
public abstract java.lang.CharSequencegetTitle()
Returns the current title of this action mode.

return
Title text

public booleangetTitleOptionalHint()

return
true if this action mode has been given a hint to consider the title/subtitle display to be optional.
see
#setTitleOptionalHint(boolean)
see
#isTitleOptional()

        return mTitleOptionalHint;
    
public abstract voidinvalidate()
Invalidate the action mode and refresh menu content. The mode's {@link ActionMode.Callback} will have its {@link 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 booleanisTitleOptional()

return
true if this action mode considers the title and subtitle fields as optional. Optional titles may not be displayed to the user.

        return false;
    
public booleanisUiFocusable()
Returns whether the UI presenting this action mode can take focus or not. This is used by internal components within the framework that would otherwise present an action mode UI that requires focus, such as an EditText as a custom view.

return
true if the UI used to show this action mode can take focus
hide
Internal use only

        return true;
    
public abstract voidsetCustomView(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.

param
view Custom view to use in place of the title/subtitle.
see
#setTitle(CharSequence)
see
#setSubtitle(CharSequence)

public abstract voidsetSubtitle(java.lang.CharSequence subtitle)
Set the subtitle of the action mode. This method will have no visible effect if a custom view has been set.

param
subtitle Subtitle string to set
see
#setSubtitle(int)
see
#setCustomView(View)

public abstract voidsetSubtitle(int resId)
Set the subtitle of the action mode. This method will have no visible effect if a custom view has been set.

param
resId Resource ID of a string to set as the subtitle
see
#setSubtitle(CharSequence)
see
#setCustomView(View)

public voidsetTag(java.lang.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.

param
tag Tag to associate with this ActionMode
see
#getTag()

        mTag = tag;
    
public abstract voidsetTitle(java.lang.CharSequence title)
Set the title of the action mode. This method will have no visible effect if a custom view has been set.

param
title Title string to set
see
#setTitle(int)
see
#setCustomView(View)

public abstract voidsetTitle(int resId)
Set the title of the action mode. This method will have no visible effect if a custom view has been set.

param
resId Resource ID of a string to set as the title
see
#setTitle(CharSequence)
see
#setCustomView(View)

public voidsetTitleOptionalHint(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.

param
titleOptional true if the title only presents optional information.

        mTitleOptionalHint = titleOptional;