AccessibilityAction
class AccessibilityAction : Parcelable
kotlin.Any | |
↳ | android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction |
A class defining an action that can be performed on an AccessibilityNodeInfo
. Each action has a unique id that is mandatory and optional data.
There are three categories of actions:
- Standard actions - These are actions that are reported and handled by the standard UI widgets in the platform. For each standard action there is a static constant defined in this class, e.g.
ACTION_FOCUS
. These actions will havenull
labels. - Custom actions action - These are actions that are reported and handled by custom widgets. i.e. ones that are not part of the UI toolkit. For example, an application may define a custom action for clearing the user history.
- Overridden standard actions - These are actions that override standard actions to customize them. For example, an app may add a label to the standard
ACTION_CLICK
action to indicate to the user that this action clears browsing history.
Actions are typically added to an AccessibilityNodeInfo
by using AccessibilityNodeInfo#addAction(AccessibilityAction)
within View#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo)
and are performed within View#performAccessibilityAction(int, Bundle)
.
Note: Views which support these actions should invoke
View#setImportantForAccessibility(int)
with View#IMPORTANT_FOR_ACCESSIBILITY_YES
to ensure an AccessibilityService
can discover the set of supported actions.
Note: Use androidx.core.view.ViewCompat#addAccessibilityAction(View, * CharSequence, AccessibilityViewCommand) to register an action directly on the view.
Summary
Inherited constants | |
---|---|
Public constructors | |
---|---|
AccessibilityAction(actionId: Int, label: CharSequence?) Creates a new AccessibilityAction. |
Public methods | |
---|---|
Int |
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. |
Boolean |
Indicates whether some other object is "equal to" this one. |
Int |
getId() Gets the id for this action. |
CharSequence! |
getLabel() Gets the label for this action. |
Int |
hashCode() |
String |
toString() |
Unit |
writeToParcel(out: Parcel, flags: Int) Write data into a parcel. |
Properties | |
---|---|
static AccessibilityNodeInfo.AccessibilityAction! |
Action that gives accessibility focus to the node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that clears accessibility focus of the node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that clears input focus of the node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that deselects the node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that clicks on the node info. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to collapse an expandable node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that context clicks the node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to copy the current selection to the clipboard. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to cut the current selection and place it to the clipboard. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to dismiss a dismissable node. |
static AccessibilityNodeInfo.AccessibilityAction |
Action to cancel a drag. |
static AccessibilityNodeInfo.AccessibilityAction |
Action to trigger a drop of the content being dragged. |
static AccessibilityNodeInfo.AccessibilityAction |
Action to start a drag. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to expand an expandable node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that gives input focus to the node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to hide a tooltip. |
static AccessibilityNodeInfo.AccessibilityAction |
Action to send an ime actionId which is from |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that long clicks on the node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to move a window to a new location. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that requests to go to the next entity in this node's text at a given movement granularity. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to move to the next HTML element of a given type. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to move to the page below. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to move to the page left. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to move to the page right. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to move to the page above. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to paste the current clipboard content. |
static AccessibilityNodeInfo.AccessibilityAction |
Action that presses and holds a node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that requests to go to the previous entity in this node's text at a given movement granularity. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to move to the previous HTML element of a given type. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to scroll the node content backward. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to scroll the node content down. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to scroll the node content forward. |
static AccessibilityNodeInfo.AccessibilityAction |
Action that brings fully on screen the next node in the specified direction. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to scroll the node content left. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to scroll the node content right. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that scrolls the node to make the specified collection position visible on screen. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to scroll the node content up. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that selects the node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that sets progress between |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to set the selection. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that sets the text of the node. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action that requests the node make its bounding rectangle visible on the screen, scrolling if necessary just enough. |
static AccessibilityNodeInfo.AccessibilityAction |
Action to show suggestions for editable text. |
static AccessibilityNodeInfo.AccessibilityAction! |
Action to show a tooltip. |
static Parcelable.Creator<AccessibilityNodeInfo.AccessibilityAction!> |
Public constructors
AccessibilityAction
AccessibilityAction(
actionId: Int,
label: CharSequence?)
Creates a new AccessibilityAction. For adding a standard action without a specific label, use the static constants. You can also override the description for one the standard actions. Below is an example how to override the standard click action by adding a custom label:
AccessibilityAction action = new AccessibilityAction( AccessibilityAction.ACTION_CLICK.getId(), getLocalizedLabel()); node.addAction(action);
Parameters | |
---|---|
actionId |
Int: The id for this action. This should either be one of the standard actions or a specific action for your app. In that case it is required to use a resource identifier. |
label |
CharSequence?: The label for the new AccessibilityAction. This value may be null . |
Public methods
describeContents
fun describeContents(): Int
Describe the kinds of special objects contained in this Parcelable instance's marshaled representation. For example, if the object will include a file descriptor in the output of writeToParcel(android.os.Parcel,int)
, the return value of this method must include the CONTENTS_FILE_DESCRIPTOR
bit.
Return | |
---|---|
Int |
a bitmask indicating the set of special object types marshaled by this Parcelable object instance. Value is either 0 or android.os.Parcelable#CONTENTS_FILE_DESCRIPTOR |
equals
fun equals(other: Any?): Boolean
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation on non-null object references:
- It is reflexive: for any non-null reference value
x
,x.equals(x)
should returntrue
. - It is symmetric: for any non-null reference values
x
andy
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any non-null reference values
x
,y
, andz
, ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
. - It is consistent: for any non-null reference values
x
andy
, multiple invocations ofx.equals(y)
consistently returntrue
or consistently returnfalse
, provided no information used inequals
comparisons on the objects is modified. - For any non-null reference value
x
,x.equals(null)
should returnfalse
.
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.
Parameters | |
---|---|
obj |
the reference object with which to compare. |
other |
Any?: This value may be null . |
Return | |
---|---|
Boolean |
true if this object is the same as the obj argument; false otherwise. |
getLabel
fun getLabel(): CharSequence!
Gets the label for this action. Its purpose is to describe the action to user.
Return | |
---|---|
CharSequence! |
The label. |
toString
fun toString(): String
Return | |
---|---|
String |
a string representation of the object. |
writeToParcel
fun writeToParcel(
out: Parcel,
flags: Int
): Unit
Write data into a parcel.
Parameters | |
---|---|
dest |
The Parcel in which the object should be written. This value cannot be null . |
flags |
Int: Additional flags about how the object should be written. May be 0 or PARCELABLE_WRITE_RETURN_VALUE . Value is either 0 or a combination of android.os.Parcelable#PARCELABLE_WRITE_RETURN_VALUE , and android.os.Parcelable.PARCELABLE_ELIDE_DUPLICATES |
out |
Parcel: This value cannot be null . |
Properties
ACTION_ACCESSIBILITY_FOCUS
static val ACTION_ACCESSIBILITY_FOCUS: AccessibilityNodeInfo.AccessibilityAction!
Action that gives accessibility focus to the node.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUSED
event if successful. The node that is focused should return true
for AccessibilityNodeInfo#isAccessibilityFocused()
.
This is intended to be used by screen readers to assist with user navigation. Apps changing focus can confuse screen readers, so the resulting behavior can vary by device and screen reader version.
This is distinct from ACTION_FOCUS
, which refers to system focus. System focus is typically used to convey targets for keyboard navigation.
ACTION_CLEAR_ACCESSIBILITY_FOCUS
static val ACTION_CLEAR_ACCESSIBILITY_FOCUS: AccessibilityNodeInfo.AccessibilityAction!
Action that clears accessibility focus of the node.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED
event if successful. The node that is cleared should return false
for AccessibilityNodeInfo#isAccessibilityFocused()
.
ACTION_CLEAR_FOCUS
static val ACTION_CLEAR_FOCUS: AccessibilityNodeInfo.AccessibilityAction!
Action that clears input focus of the node.
The node that is cleared should return false
for )
.
ACTION_CLEAR_SELECTION
static val ACTION_CLEAR_SELECTION: AccessibilityNodeInfo.AccessibilityAction!
Action that deselects the node.
ACTION_CLICK
static val ACTION_CLICK: AccessibilityNodeInfo.AccessibilityAction!
Action that clicks on the node info.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_CLICKED
event. In the View system, the default handling of this action when performed by a service is to call View#performClick()
, and setting a View#setOnClickListener(View.OnClickListener)
automatically adds this action.
isClickable()
should return true if this action is available.
ACTION_COLLAPSE
static val ACTION_COLLAPSE: AccessibilityNodeInfo.AccessibilityAction!
Action to collapse an expandable node.
ACTION_CONTEXT_CLICK
static val ACTION_CONTEXT_CLICK: AccessibilityNodeInfo.AccessibilityAction!
Action that context clicks the node.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_CONTEXT_CLICKED
event. In the View system, the default handling of this action when performed by a service is to call View#performContextClick()
, and setting a View#setOnContextClickListener(View.OnContextClickListener)
automatically adds this action.
A context click usually occurs from a mouse pointer right-click or a stylus button press.
isContextClickable()
should return true if this action is available.
ACTION_COPY
static val ACTION_COPY: AccessibilityNodeInfo.AccessibilityAction!
Action to copy the current selection to the clipboard.
ACTION_CUT
static val ACTION_CUT: AccessibilityNodeInfo.AccessibilityAction!
Action to cut the current selection and place it to the clipboard.
ACTION_DISMISS
static val ACTION_DISMISS: AccessibilityNodeInfo.AccessibilityAction!
Action to dismiss a dismissable node.
ACTION_DRAG_CANCEL
static val ACTION_DRAG_CANCEL: AccessibilityNodeInfo.AccessibilityAction
Action to cancel a drag.
This action is added to the source that started a drag with ACTION_DRAG_START
.
ACTION_DRAG_DROP
static val ACTION_DRAG_DROP: AccessibilityNodeInfo.AccessibilityAction
Action to trigger a drop of the content being dragged.
This action is added to potential drop targets if the source started a drag with ACTION_DRAG_START
. In View, these targets are Views that accepted android.view.DragEvent#ACTION_DRAG_STARTED
and have an View.OnDragListener
, and the drop occurs at the center location of the View's window bounds.
ACTION_DRAG_START
static val ACTION_DRAG_START: AccessibilityNodeInfo.AccessibilityAction
Action to start a drag.
This action initiates a drag & drop within the system. The source's dragged content is prepared before the drag begins. In View, this action should prepare the arguments to View#startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int)
and then call View#startDragAndDrop(ClipData, View.DragShadowBuilder, Object, int)
with View#DRAG_FLAG_ACCESSIBILITY_ACTION
. The equivalent should be performed for other UI toolkits.
ACTION_EXPAND
static val ACTION_EXPAND: AccessibilityNodeInfo.AccessibilityAction!
Action to expand an expandable node.
ACTION_FOCUS
static val ACTION_FOCUS: AccessibilityNodeInfo.AccessibilityAction!
Action that gives input focus to the node.
The focus request send an event of AccessibilityEvent#TYPE_VIEW_FOCUSED
if successful. In the View system, this is handled by android.view.View#requestFocus.
The node that is focused should return true
for AccessibilityNodeInfo#isFocused()
. See ACTION_ACCESSIBILITY_FOCUS
for the difference between system and accessibility focus.
ACTION_HIDE_TOOLTIP
static val ACTION_HIDE_TOOLTIP: AccessibilityNodeInfo.AccessibilityAction!
Action to hide a tooltip. A node should expose this action only for views that are currently showing a tooltip.
ACTION_IME_ENTER
static val ACTION_IME_ENTER: AccessibilityNodeInfo.AccessibilityAction
Action to send an ime actionId which is from android.view.inputmethod.EditorInfo#actionId
. This ime actionId sets by TextView#setImeActionLabel(CharSequence, int)
, or it would be android.view.inputmethod.EditorInfo#IME_ACTION_UNSPECIFIED
if no specific actionId has set. A node should expose this action only for views that are currently with input focus and editable.
ACTION_LONG_CLICK
static val ACTION_LONG_CLICK: AccessibilityNodeInfo.AccessibilityAction!
Action that long clicks on the node.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_LONG_CLICKED
event. In the View system, the default handling of this action when performed by a service is to call View#performLongClick()
, and setting a View#setOnLongClickListener(View.OnLongClickListener)
automatically adds this action.
isLongClickable()
should return true if this action is available.
ACTION_MOVE_WINDOW
static val ACTION_MOVE_WINDOW: AccessibilityNodeInfo.AccessibilityAction!
Action to move a window to a new location.
Arguments: AccessibilityNodeInfo#ACTION_ARGUMENT_MOVE_WINDOW_X
AccessibilityNodeInfo#ACTION_ARGUMENT_MOVE_WINDOW_Y
ACTION_NEXT_AT_MOVEMENT_GRANULARITY
static val ACTION_NEXT_AT_MOVEMENT_GRANULARITY: AccessibilityNodeInfo.AccessibilityAction!
Action that requests to go to the next entity in this node's text at a given movement granularity. For example, move to the next character, word, etc.
Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
, AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Example: Move to the previous character and do not extend selection.
<p><code> Bundle arguments = new Bundle(); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, false); info.performAction(AccessibilityAction.ACTION_NEXT_AT_MOVEMENT_GRANULARITY.getId(), arguments); </code></p>
See Also
android.view.accessibility.AccessibilityNodeInfo#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
android.view.accessibility.AccessibilityNodeInfo#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
android.view.accessibility.AccessibilityNodeInfo#setMovementGranularities(int)
android.view.accessibility.AccessibilityNodeInfo#getMovementGranularities()
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_CHARACTER
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_WORD
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_LINE
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_PARAGRAPH
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_PAGE
ACTION_NEXT_HTML_ELEMENT
static val ACTION_NEXT_HTML_ELEMENT: AccessibilityNodeInfo.AccessibilityAction!
Action to move to the next HTML element of a given type. For example, move to the BUTTON, INPUT, TABLE, etc.
Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:
<p><code> Bundle arguments = new Bundle(); arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); info.performAction(AccessibilityAction.ACTION_NEXT_HTML_ELEMENT.getId(), arguments); </code></p>
ACTION_PAGE_DOWN
static val ACTION_PAGE_DOWN: AccessibilityNodeInfo.AccessibilityAction!
Action to move to the page below.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_PAGE_LEFT
static val ACTION_PAGE_LEFT: AccessibilityNodeInfo.AccessibilityAction!
Action to move to the page left.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_PAGE_RIGHT
static val ACTION_PAGE_RIGHT: AccessibilityNodeInfo.AccessibilityAction!
Action to move to the page right.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_PAGE_UP
static val ACTION_PAGE_UP: AccessibilityNodeInfo.AccessibilityAction!
Action to move to the page above.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_PASTE
static val ACTION_PASTE: AccessibilityNodeInfo.AccessibilityAction!
Action to paste the current clipboard content.
ACTION_PRESS_AND_HOLD
static val ACTION_PRESS_AND_HOLD: AccessibilityNodeInfo.AccessibilityAction
Action that presses and holds a node.
This action is for nodes that have distinct behavior that depends on how long a press is held. Nodes having a single action for long press should use ACTION_LONG_CLICK
instead of this action, and nodes should not expose both actions.
When calling performAction(ACTION_PRESS_AND_HOLD, bundle
, use ACTION_ARGUMENT_PRESS_AND_HOLD_DURATION_MILLIS_INT
to specify how long the node is pressed. The first time an accessibility service performs ACTION_PRES_AND_HOLD on a node, it must specify 0 as ACTION_ARGUMENT_PRESS_AND_HOLD, so the application is notified that the held state has started. To ensure reasonable behavior, the values must be increased incrementally and may not exceed 10,000. UIs requested to hold for times outside of this range should ignore the action.
The total time the element is held could be specified by an accessibility user up-front, or may depend on what happens on the UI as the user continues to request the hold.
Note: The time between dispatching the action and it arriving in the UI process is not guaranteed. It is possible on a busy system for the time to expire unexpectedly. For the case of holding down a key for a repeating action, a delayed arrival should be benign. Please do not use this sort of action in cases where such delays will lead to unexpected UI behavior.
ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY
static val ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY: AccessibilityNodeInfo.AccessibilityAction!
Action that requests to go to the previous entity in this node's text at a given movement granularity. For example, move to the next character, word, etc.
Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
, AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
Example: Move to the next character and do not extend selection.
<p><code> Bundle arguments = new Bundle(); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT, AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER); arguments.putBoolean(AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN, false); info.performAction(AccessibilityAction.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY.getId(), arguments); </code></p>
See Also
android.view.accessibility.AccessibilityNodeInfo#ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT
android.view.accessibility.AccessibilityNodeInfo#ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN
android.view.accessibility.AccessibilityNodeInfo#setMovementGranularities(int)
android.view.accessibility.AccessibilityNodeInfo#getMovementGranularities()
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_CHARACTER
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_WORD
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_LINE
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_PARAGRAPH
android.view.accessibility.AccessibilityNodeInfo#MOVEMENT_GRANULARITY_PAGE
ACTION_PREVIOUS_HTML_ELEMENT
static val ACTION_PREVIOUS_HTML_ELEMENT: AccessibilityNodeInfo.AccessibilityAction!
Action to move to the previous HTML element of a given type. For example, move to the BUTTON, INPUT, TABLE, etc.
Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING
Example:
<p><code> Bundle arguments = new Bundle(); arguments.putString(AccessibilityNodeInfo.ACTION_ARGUMENT_HTML_ELEMENT_STRING, "BUTTON"); info.performAction(AccessibilityAction.ACTION_PREVIOUS_HTML_ELEMENT.getId(), arguments); </code></p>
ACTION_SCROLL_BACKWARD
static val ACTION_SCROLL_BACKWARD: AccessibilityNodeInfo.AccessibilityAction!
Action to scroll the node content backward.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event. Depending on the orientation, this element should also add the relevant directional scroll actions of ACTION_SCROLL_LEFT
, ACTION_SCROLL_RIGHT
, ACTION_SCROLL_UP
, and ACTION_SCROLL_DOWN
. If the scrolling brings the next or previous element into view as the center element, such as in a ViewPager2, use ACTION_PAGE_DOWN
and the other page actions instead of the directional actions.
Example: a scrolling UI of horizontal orientation with a backward scroll action should also add the scroll left/right action (LTR/RTL):
<code> onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); if (canScrollBackward) { info.addAction(ACTION_SCROLL_FORWARD); if (leftToRight) { info.addAction(ACTION_SCROLL_LEFT); } else { info.addAction(ACTION_SCROLL_RIGHT); } } } performAccessibilityAction(int action, Bundle bundle) { if (action == ACTION_SCROLL_BACKWARD) { scrollBackward(); } else if (action == ACTION_SCROLL_LEFT) { if (!isRTL()){ scrollBackward(); } } else if (action == ACTION_SCROLL_RIGHT) { if (isRTL()){ scrollBackward(); } } } scrollBackward() { ... if (mAccessibilityManager.isEnabled()) { event = new AccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SCROLLED); event.setScrollDeltaX(dx); event.setScrollDeltaY(dy); event.setMaxScrollX(maxDx); event.setMaxScrollY(maxDY); sendAccessibilityEventUnchecked(event); } } </code>
ACTION_SCROLL_DOWN
static val ACTION_SCROLL_DOWN: AccessibilityNodeInfo.AccessibilityAction!
Action to scroll the node content down.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_SCROLL_FORWARD
static val ACTION_SCROLL_FORWARD: AccessibilityNodeInfo.AccessibilityAction!
Action to scroll the node content forward.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event. Depending on the orientation, this element should also add the relevant directional scroll actions of ACTION_SCROLL_LEFT
, ACTION_SCROLL_RIGHT
, ACTION_SCROLL_UP
, and ACTION_SCROLL_DOWN
. If the scrolling brings the next or previous element into view as the center element, such as in a ViewPager2, use ACTION_PAGE_DOWN
and the other page actions instead of the directional actions.
Example: a scrolling UI of vertical orientation with a forward scroll action should also add the scroll down action:
<code> onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { super.onInitializeAccessibilityNodeInfo(info); if (canScrollForward) { info.addAction(ACTION_SCROLL_FORWARD); info.addAction(ACTION_SCROLL_DOWN); } } performAccessibilityAction(int action, Bundle bundle) { if (action == ACTION_SCROLL_FORWARD || action == ACTION_SCROLL_DOWN) { scrollForward(); } } scrollForward() { ... if (mAccessibilityManager.isEnabled()) { event = new AccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SCROLLED); event.setScrollDeltaX(dx); event.setScrollDeltaY(dy); event.setMaxScrollX(maxDx); event.setMaxScrollY(maxDY); sendAccessibilityEventUnchecked(event); } } </code>
ACTION_SCROLL_IN_DIRECTION
static val ACTION_SCROLL_IN_DIRECTION: AccessibilityNodeInfo.AccessibilityAction
Action that brings fully on screen the next node in the specified direction.
This should include wrapping around to the next/previous row, column, etc. in a collection if one is available. If there is no node in that direction, the action should fail and return false.
This action should be used instead of AccessibilityAction#ACTION_SCROLL_TO_POSITION
when a widget does not have clear row and column semantics or if a directional search is needed to find a node in a complex ViewGroup where individual nodes may span multiple rows or columns. The implementing widget must send a AccessibilityEvent#TYPE_VIEW_TARGETED_BY_SCROLL
accessibility event with the scroll target as the source. An accessibility service can listen for this event, inspect its source, and use the result when determining where to place accessibility focus.
Arguments: ACTION_ARGUMENT_DIRECTION_INT
. This is a required argument.
ACTION_SCROLL_LEFT
static val ACTION_SCROLL_LEFT: AccessibilityNodeInfo.AccessibilityAction!
Action to scroll the node content left.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_SCROLL_RIGHT
static val ACTION_SCROLL_RIGHT: AccessibilityNodeInfo.AccessibilityAction!
Action to scroll the node content right.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_SCROLL_TO_POSITION
static val ACTION_SCROLL_TO_POSITION: AccessibilityNodeInfo.AccessibilityAction!
Action that scrolls the node to make the specified collection position visible on screen.
Arguments:
AccessibilityNodeInfo#ACTION_ARGUMENT_ROW_INT
AccessibilityNodeInfo#ACTION_ARGUMENT_COLUMN_INT
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_SCROLL_UP
static val ACTION_SCROLL_UP: AccessibilityNodeInfo.AccessibilityAction!
Action to scroll the node content up.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_SELECT
static val ACTION_SELECT: AccessibilityNodeInfo.AccessibilityAction!
Action that selects the node. The view the implements this should send a AccessibilityEvent#TYPE_VIEW_SELECTED
event.
ACTION_SET_PROGRESS
static val ACTION_SET_PROGRESS: AccessibilityNodeInfo.AccessibilityAction!
Action that sets progress between RangeInfo.getMin()
and RangeInfo.getMax()
. It should use the same value type as RangeInfo.getType()
Arguments: AccessibilityNodeInfo#ACTION_ARGUMENT_PROGRESS_VALUE
ACTION_SET_SELECTION
static val ACTION_SET_SELECTION: AccessibilityNodeInfo.AccessibilityAction!
Action to set the selection. Performing this action with no arguments clears the selection.
Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT
, AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT
Example:
<p><code> Bundle arguments = new Bundle(); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, 1); arguments.putInt(AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, 2); info.performAction(AccessibilityAction.ACTION_SET_SELECTION.getId(), arguments); </code></p>
If this is a text selection, the UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_TEXT_SELECTION_CHANGED
event if its selection is updated. This element should also return true
for AccessibilityNodeInfo#isTextSelectable()
.
ACTION_SET_TEXT
static val ACTION_SET_TEXT: AccessibilityNodeInfo.AccessibilityAction!
Action that sets the text of the node. Performing the action without argument, using null
or empty CharSequence
will clear the text. This action will also put the cursor at the end of text.
Arguments: AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE
Example:
<p><code> Bundle arguments = new Bundle(); arguments.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, "android"); info.performAction(AccessibilityAction.ACTION_SET_TEXT.getId(), arguments); </code></p>
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_TEXT_CHANGED
event if its text is updated. This element should also return true
for AccessibilityNodeInfo#isEditable()
.
ACTION_SHOW_ON_SCREEN
static val ACTION_SHOW_ON_SCREEN: AccessibilityNodeInfo.AccessibilityAction!
Action that requests the node make its bounding rectangle visible on the screen, scrolling if necessary just enough.
The UI element that implements this should send a AccessibilityEvent#TYPE_VIEW_SCROLLED
event.
ACTION_SHOW_TEXT_SUGGESTIONS
static val ACTION_SHOW_TEXT_SUGGESTIONS: AccessibilityNodeInfo.AccessibilityAction
Action to show suggestions for editable text.
ACTION_SHOW_TOOLTIP
static val ACTION_SHOW_TOOLTIP: AccessibilityNodeInfo.AccessibilityAction!
Action to show a tooltip. A node should expose this action only for views with tooltip text that but are not currently showing a tooltip.
CREATOR
static val CREATOR: Parcelable.Creator<AccessibilityNodeInfo.AccessibilityAction!>