AccessibilityNodeProviderCompat
public
class
AccessibilityNodeProviderCompat
extends Object
java.lang.Object | |
↳ | androidx.core.view.accessibility.AccessibilityNodeProviderCompat |
Helper for accessing AccessibilityNodeProvider
.
Summary
Constants | |
---|---|
int |
HOST_VIEW_ID
The virtual id for the hosting View. |
Public constructors | |
---|---|
AccessibilityNodeProviderCompat()
Creates a new instance. |
|
AccessibilityNodeProviderCompat(Object provider)
Creates a new instance wrapping an
|
Public methods | |
---|---|
void
|
addExtraDataToAccessibilityNodeInfo(int virtualViewId, AccessibilityNodeInfoCompat info, String extraDataKey, Bundle arguments)
Adds extra data to an |
AccessibilityNodeInfoCompat
|
createAccessibilityNodeInfo(int virtualViewId)
Returns an |
List<AccessibilityNodeInfoCompat>
|
findAccessibilityNodeInfosByText(String text, int virtualViewId)
Finds |
AccessibilityNodeInfoCompat
|
findFocus(int focus)
Find the virtual view, i.e. |
Object
|
getProvider()
|
boolean
|
performAction(int virtualViewId, int action, Bundle arguments)
Performs an accessibility action on a virtual view, i.e. |
Inherited methods | |
---|---|
Constants
HOST_VIEW_ID
public static final int HOST_VIEW_ID
The virtual id for the hosting View.
Constant Value: -1 (0xffffffff)
Public constructors
AccessibilityNodeProviderCompat
public AccessibilityNodeProviderCompat ()
Creates a new instance.
AccessibilityNodeProviderCompat
public AccessibilityNodeProviderCompat (Object provider)
Creates a new instance wrapping an
AccessibilityNodeProvider
.
Parameters | |
---|---|
provider |
Object : The provider.
|
Public methods
addExtraDataToAccessibilityNodeInfo
public void addExtraDataToAccessibilityNodeInfo (int virtualViewId, AccessibilityNodeInfoCompat info, String extraDataKey, Bundle arguments)
Adds extra data to an AccessibilityNodeInfoCompat
based on an explicit request for
the additional data.
This method only needs to be implemented if a virtual view offers to provide additional data.
Parameters | |
---|---|
virtualViewId |
int : The virtual view id used to create the node |
info |
AccessibilityNodeInfoCompat : The info to which to add the extra data |
extraDataKey |
String : A key specifying the type of extra data to add to the info. The
extra data should be added to the Bundle returned by
the info's AccessibilityNodeInfoCompat.getExtras() method. |
arguments |
Bundle : A Bundle holding any arguments relevant for this request. |
createAccessibilityNodeInfo
public AccessibilityNodeInfoCompat createAccessibilityNodeInfo (int virtualViewId)
Returns an AccessibilityNodeInfoCompat
representing a virtual view,
i.e. a descendant of the host View, with the given virtualViewId
or the host View itself if virtualViewId
equals to HOST_VIEW_ID
.
A virtual descendant is an imaginary View that is reported as a part of the view hierarchy for accessibility purposes. This enables custom views that draw complex content to report them selves as a tree of virtual views, thus conveying their logical structure.
The implementer is responsible for obtaining an accessibility node info from the pool of reusable instances and setting the desired properties of the node info before returning it.
Parameters | |
---|---|
virtualViewId |
int : A client defined virtual view id. |
Returns | |
---|---|
AccessibilityNodeInfoCompat |
A populated AccessibilityNodeInfoCompat for a virtual descendant
or the host View. |
See also:
findAccessibilityNodeInfosByText
public List<AccessibilityNodeInfoCompat> findAccessibilityNodeInfosByText (String text, int virtualViewId)
Finds AccessibilityNodeInfoCompat
s by text. The match is case insensitive
containment. The search is relative to the virtual view, i.e. a descendant of the
host View, with the given virtualViewId
or the host View itself
virtualViewId
equals to HOST_VIEW_ID
.
Parameters | |
---|---|
text |
String : The searched text. |
virtualViewId |
int : A client defined virtual view id which defined
the root of the tree in which to perform the search. |
Returns | |
---|---|
List<AccessibilityNodeInfoCompat> |
A list of node info. |
findFocus
public AccessibilityNodeInfoCompat findFocus (int focus)
Find the virtual view, i.e. a descendant of the host View, that has the specified focus type.
Parameters | |
---|---|
focus |
int : The focus to find. One of
AccessibilityNodeInfoCompat.FOCUS_INPUT or
AccessibilityNodeInfoCompat.FOCUS_ACCESSIBILITY . |
Returns | |
---|---|
AccessibilityNodeInfoCompat |
The node info of the focused view or null. |
performAction
public boolean performAction (int virtualViewId, int action, Bundle arguments)
Performs an accessibility action on a virtual view, i.e. a descendant of the
host View, with the given virtualViewId
or the host View itself
if virtualViewId
equals to HOST_VIEW_ID
.
Parameters | |
---|---|
virtualViewId |
int : A client defined virtual view id. |
action |
int : The action to perform. |
arguments |
Bundle : Optional arguments. |
Returns | |
---|---|
boolean |
True if the action was performed. |