RecyclerViewAccessibilityDelegate

public class RecyclerViewAccessibilityDelegate extends AccessibilityDelegateCompat


The AccessibilityDelegate used by RecyclerView.

This class handles basic accessibility actions and delegates them to LayoutManager.

Summary

Nested types

The default implementation of accessibility delegate for the individual items of the RecyclerView.

Public constructors

Public methods

@NonNull AccessibilityDelegateCompat

Gets the AccessibilityDelegate for an individual item in the RecyclerView.

void

Initializes an AccessibilityEvent with information about the the host View which is the event source.

void

Initializes an AccessibilityNodeInfoCompat with information about the host view.

boolean
performAccessibilityAction(
    @NonNull View host,
    int action,
    @Nullable Bundle args
)

Performs the specified accessibility action on the view.

Inherited methods

From androidx.core.view.AccessibilityDelegateCompat
boolean

Dispatches an AccessibilityEvent to the host View first and then to its children for adding their text content to the event.

@Nullable AccessibilityNodeProviderCompat

Gets the provider for managing a virtual view hierarchy rooted at this View and reported to AccessibilityServices that explore the window content.

void

Gives a chance to the host View to populate the accessibility event with its text content.

boolean

Called when a child of the host View has requested sending an AccessibilityEvent and gives an opportunity to the parent (the host) to augment the event.

void
sendAccessibilityEvent(@NonNull View host, int eventType)

Sends an accessibility event of the given type.

void

Sends an accessibility event.

Public constructors

RecyclerViewAccessibilityDelegate

Added in 1.0.0
public RecyclerViewAccessibilityDelegate(@NonNull RecyclerView recyclerView)

Public methods

getItemDelegate

Added in 1.0.0
public @NonNull AccessibilityDelegateCompat getItemDelegate()

Gets the AccessibilityDelegate for an individual item in the RecyclerView. A basic item delegate is provided by default, but you can override this method to provide a custom per-item delegate. For now, returning an AccessibilityDelegateCompat as opposed to an ItemDelegate will prevent use of the ViewCompat accessibility API on item views.

onInitializeAccessibilityEvent

public void onInitializeAccessibilityEvent(
    @NonNull View host,
    @NonNull AccessibilityEvent event
)

Initializes an AccessibilityEvent with information about the the host View which is the event source.

The default implementation behaves as ViewCompat#onInitalizeAccessibilityEvent(View v, AccessibilityEvent event) for the case of no accessibility delegate been set.

Parameters
@NonNull View host

The View hosting the delegate.

@NonNull AccessibilityEvent event

The event to initialize.

See also
onInitializeAccessibilityEvent

ViewCompat#onInitializeAccessibilityEvent(View, AccessibilityEvent)

onInitializeAccessibilityNodeInfo

public void onInitializeAccessibilityNodeInfo(
    @NonNull View host,
    @NonNull AccessibilityNodeInfoCompat info
)

Initializes an AccessibilityNodeInfoCompat with information about the host view.

The default implementation behaves as ViewCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat) for the case of no accessibility delegate been set.

Parameters
@NonNull View host

The View hosting the delegate.

@NonNull AccessibilityNodeInfoCompat info

The instance to initialize.

See also
onInitializeAccessibilityNodeInfo

ViewCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat)

performAccessibilityAction

public boolean performAccessibilityAction(
    @NonNull View host,
    int action,
    @Nullable Bundle args
)

Performs the specified accessibility action on the view. For possible accessibility actions look at AccessibilityNodeInfoCompat.

The default implementation behaves as View#performAccessibilityAction(int, Bundle) for the case of no accessibility delegate been set.

Parameters
@NonNull View host

View on which to perform the action.

int action

The action to perform.

@Nullable Bundle args

Optional action arguments.

Returns
boolean

Whether the action was performed.

See also
performAccessibilityAction

View#performAccessibilityAction(int, Bundle)