java.lang.Object | ||
↳ | android.support.v4.view.AccessibilityDelegateCompat | |
↳ | android.support.v4.widget.ExploreByTouchHelper |
ExploreByTouchHelper is a utility class for implementing accessibility
support in custom
View
s that represent a collection of View-like
logical items. It extends
AccessibilityNodeProviderCompat
and
simplifies many aspects of providing information to accessibility services
and managing accessibility focus. This class does not currently support
hierarchies of logical items.
This should be applied to the parent view using
setAccessibilityDelegate(View, AccessibilityDelegateCompat)
:
mAccessHelper = ExploreByTouchHelper.create(someView, mAccessHelperCallback); ViewCompat.setAccessibilityDelegate(someView, mAccessHelper);
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | INVALID_ID | Virtual node identifier value for invalid nodes. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Factory method to create a new
ExploreByTouchHelper
.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Dispatches hover
MotionEvent
s to the virtual view hierarchy when
the Explore by Touch feature is enabled.
|
||||||||||
|
Returns the
AccessibilityNodeProviderCompat
for this helper.
|
||||||||||
|
Returns the virtual view id for the currently focused item,
|
||||||||||
|
Notifies the accessibility framework that the properties of the parent
view have changed.
|
||||||||||
|
Notifies the accessibility framework that the properties of a particular
item have changed.
|
||||||||||
|
Populates an event of the specified type with information about an item
and attempts to send it up through the view hierarchy.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
|
Provides a mapping between view-relative coordinates and logical
items.
|
||||||||||
|
Populates a list with the view's visible items.
|
||||||||||
|
Performs the specified accessibility action on the item associated
with the virtual view identifier.
|
||||||||||
|
Populates an
AccessibilityEvent
with information about the
specified item.
|
||||||||||
|
Populates an
AccessibilityNodeInfoCompat
with information
about the specified item.
|
[Expand]
Inherited Methods
|
|||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
android.support.v4.view.AccessibilityDelegateCompat
|
|||||||||||
From class
java.lang.Object
|
Virtual node identifier value for invalid nodes.
Factory method to create a new
ExploreByTouchHelper
.
forView | View whose logical children are exposed by this helper. |
---|
Dispatches hover
MotionEvent
s to the virtual view hierarchy when
the Explore by Touch feature is enabled.
This method should be called by overriding
dispatchHoverEvent(MotionEvent)
:
@Override public boolean dispatchHoverEvent(MotionEvent event) { if (mHelper.dispatchHoverEvent(this, event) { return true; } return super.dispatchHoverEvent(event); }
event | The hover event to dispatch to the virtual view hierarchy. |
---|
Returns the
AccessibilityNodeProviderCompat
for this helper.
host | View whose logical children are exposed by this helper. |
---|
Returns the virtual view id for the currently focused item,
INVALID_ID
if no item is
currently focused.
Notifies the accessibility framework that the properties of the parent view have changed.
You must call this method after adding or removing items from the parent view.
Notifies the accessibility framework that the properties of a particular item have changed.
You
must
call this method after changing any of the properties set
in
onPopulateNodeForVirtualView(int, AccessibilityNodeInfoCompat)
.
virtualViewId | The virtual view id to invalidate. |
---|
Populates an event of the specified type with information about an item and attempts to send it up through the view hierarchy.
You should call this method after performing a user action that normally fires an accessibility event, such as clicking on an item.
public void performItemClick(T item) { ... sendEventForVirtualViewId(item.id, AccessibilityEvent.TYPE_VIEW_CLICKED); }
virtualViewId | The virtual view id for which to send an event. |
---|---|
eventType | The type of event to send. |
Provides a mapping between view-relative coordinates and logical items.
x | The view-relative x coordinate |
---|---|
y | The view-relative y coordinate |
Populates a list with the view's visible items. The ordering of items
within
virtualViewIds
specifies order of accessibility focus
traversal.
virtualViewIds | The list to populate with visible items |
---|
Performs the specified accessibility action on the item associated
with the virtual view identifier. See
performAction(int, Bundle)
for
more information.
Implementations
must
handle any actions added manually in
onPopulateNodeForVirtualView(int, AccessibilityNodeInfoCompat)
.
The helper class automatically handles focus management resulting
from
ACTION_ACCESSIBILITY_FOCUS
and
ACTION_CLEAR_ACCESSIBILITY_FOCUS
actions.
virtualViewId | The virtual view identifier of the item on which to perform the action |
---|---|
action | The accessibility action to perform |
arguments | (Optional) A bundle with additional arguments, or null |
Populates an
AccessibilityEvent
with information about the
specified item.
Implementations must populate the following required fields:
getText()
or
setContentDescription(CharSequence)
The helper class automatically populates the following fields with default values, but implementations may optionally override them:
setClassName(CharSequence)
The following required fields are automatically populated by the helper class and may not be overridden:
Context
, see
setPackageName(CharSequence)
setSource(View, int)
virtualViewId | The virtual view id for the item for which to populate the event |
---|---|
event | The event to populate |
Populates an
AccessibilityNodeInfoCompat
with information
about the specified item.
Implementations must populate the following required fields:
setText(CharSequence)
or
setContentDescription(CharSequence)
setBoundsInParent(Rect)
The helper class automatically populates the following fields with default values, but implementations may optionally override them:
setEnabled(boolean)
onPopulateEventForVirtualView(int, AccessibilityEvent)
, see
setClassName(CharSequence)
The following required fields are automatically populated by the helper class and may not be overridden:
onPopulateEventForVirtualView(int, AccessibilityEvent)
, see
setPackageName(CharSequence)
onPopulateEventForVirtualView(int, AccessibilityEvent)
, see
setSource(View, int)
setParent(View)
setVisibleToUser(boolean)
setAccessibilityFocused(boolean)
setBoundsInScreen(Rect)
Additionally, the helper class automatically handles accessibility
focus management by adding the appropriate
ACTION_ACCESSIBILITY_FOCUS
or
ACTION_CLEAR_ACCESSIBILITY_FOCUS
action. Implementations must
never
manually add these actions.
The helper class also automatically modifies parent- and screen-relative bounds to reflect the portion of the item visible within its parent.
virtualViewId | The virtual view identifier of the item for which to populate the node |
---|---|
node | The node to populate |