# AccessibilityDelegateCompat

Artifact: [androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core) [View Source](https://cs.android.com/search?q=file:androidx/core/view/AccessibilityDelegateCompat.java+class:androidx.core.view.AccessibilityDelegateCompat) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***


```
public class AccessibilityDelegateCompat
```

<br />

Known direct subclasses [ExploreByTouchHelper](https://developer.android.com/reference/androidx/customview/widget/ExploreByTouchHelper), [RecyclerViewAccessibilityDelegate.ItemDelegate](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerViewAccessibilityDelegate.ItemDelegate), [RecyclerViewAccessibilityDelegate](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerViewAccessibilityDelegate)

|---|---|
| `https://developer.android.com/reference/androidx/customview/widget/ExploreByTouchHelper` | ExploreByTouchHelper is a utility class for implementing accessibility support in custom `https://developer.android.com/reference/android/view/View.html`s that represent a collection of View-like logical items. |
| `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerViewAccessibilityDelegate.ItemDelegate` | The default implementation of accessibility delegate for the individual items of the RecyclerView. |
| `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerViewAccessibilityDelegate` | The AccessibilityDelegate used by RecyclerView. |

*** ** * ** ***

Helper for accessing `https://developer.android.com/reference/android/view/View.AccessibilityDelegate.html`.

**Note:** On platform versions prior to `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#M`, delegate methods on views in the `android.widget.*` package are called *before* host methods. This prevents certain properties such as class name from being modified by overriding `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#onInitializeAccessibilityNodeInfo(android.view.View,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)`, as any changes will be overwritten by the host class.

Starting in `https://developer.android.com/reference/android/os/Build.VERSION_CODES.html#M`, delegate methods are called *after* host methods, which all properties to be modified without being overwritten by the host class.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#AccessibilityDelegateCompat()()` Creates a new instance. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#dispatchPopulateAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event )` Dispatches an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html` to the host `https://developer.android.com/reference/android/view/View.html` first and then to its children for adding their text content to the event. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat` | `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#getAccessibilityNodeProvider(android.view.View)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host)` Gets the provider for managing a virtual view hierarchy rooted at this View and reported to `https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html`s that explore the window content. |
| `void` | `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#onInitializeAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event )` Initializes an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html` with information about the the host View which is the event source. |
| `void` | `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#onInitializeAccessibilityNodeInfo(android.view.View,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat info )` Initializes an `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` with information about the host view. |
| `void` | `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#onPopulateAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event )` Gives a chance to the host View to populate the accessibility event with its text content. |
| `boolean` | `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#onRequestSendAccessibilityEvent(android.view.ViewGroup,android.view.View,android.view.accessibility.AccessibilityEvent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html host, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html child, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event )` Called when a child of the host View has requested sending an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html` and gives an opportunity to the parent (the host) to augment the event. |
| `boolean` | `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#performAccessibilityAction(android.view.View,int,android.os.Bundle)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host, int action, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html args )` Performs the specified accessibility action on the view. |
| `void` | `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#sendAccessibilityEvent(android.view.View,int)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host, int eventType)` Sends an accessibility event of the given type. |
| `void` | `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#sendAccessibilityEventUnchecked(android.view.View,android.view.accessibility.AccessibilityEvent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event )` Sends an accessibility event. |

## Public constructors

### AccessibilityDelegateCompat

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public AccessibilityDelegateCompat()
```

Creates a new instance.

## Public methods

### dispatchPopulateAccessibilityEvent

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean dispatchPopulateAccessibilityEvent(
    @NonNull View host,
    @NonNull AccessibilityEvent event
)
```

Dispatches an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html` to the host `https://developer.android.com/reference/android/view/View.html` first and then to its children for adding their text content to the event.

The default implementation behaves as `https://developer.android.com/reference/android/view/View.html#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent)` for the case of no accessibility delegate been set.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host` | The View hosting the delegate. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event` | The event. |

| Returns |
|---|---|
| `boolean` | True if the event population was completed. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent)` | View#dispatchPopulateAccessibilityEvent(AccessibilityEvent) |

### getAccessibilityNodeProvider

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public @Nullable AccessibilityNodeProviderCompat getAccessibilityNodeProvider(@NonNull View host)
```

Gets the provider for managing a virtual view hierarchy rooted at this View and reported to `https://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html`s that explore the window content.

The default implementation behaves as `https://developer.android.com/reference/androidx/core/view/ViewCompat#getAccessibilityNodeProvider(android.view.View)` for the case of no accessibility delegate been set.

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat` | The provider. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeProviderCompat` |   |

### onInitializeAccessibilityEvent

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

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

Initializes an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html` with information about the the host View which is the event source.

The default implementation behaves as `https://developer.android.com/reference/androidx/core/view/ViewCompat#onInitializeAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)` for the case of no accessibility delegate been set.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host` | The View hosting the delegate. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event` | The event to initialize. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/ViewCompat#onInitializeAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)` | ViewCompat#onInitializeAccessibilityEvent(View, AccessibilityEvent) |

### onInitializeAccessibilityNodeInfo

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

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

Initializes an `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat` with information about the host view.

The default implementation behaves as `https://developer.android.com/reference/androidx/core/view/ViewCompat#onInitializeAccessibilityNodeInfo(android.view.View,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)` for the case of no accessibility delegate been set.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host` | The View hosting the delegate. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat info` | The instance to initialize. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/ViewCompat#onInitializeAccessibilityNodeInfo(android.view.View,androidx.core.view.accessibility.AccessibilityNodeInfoCompat)` | ViewCompat#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfoCompat) |

### onPopulateAccessibilityEvent

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void onPopulateAccessibilityEvent(
    @NonNull View host,
    @NonNull AccessibilityEvent event
)
```

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

The default implementation behaves as `https://developer.android.com/reference/androidx/core/view/ViewCompat#onPopulateAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)` for the case of no accessibility delegate been set.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host` | The View hosting the delegate. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event` | The accessibility event which to populate. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/ViewCompat#onPopulateAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)` | ViewCompat#onPopulateAccessibilityEvent(View, AccessibilityEvent) |

### onRequestSendAccessibilityEvent

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public boolean onRequestSendAccessibilityEvent(
    @NonNull ViewGroup host,
    @NonNull View child,
    @NonNull AccessibilityEvent event
)
```

Called when a child of the host View has requested sending an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html` and gives an opportunity to the parent (the host) to augment the event.

The default implementation behaves as `https://developer.android.com/reference/androidx/core/view/ViewGroupCompat#onRequestSendAccessibilityEvent(android.view.ViewGroup,android.view.View,android.view.accessibility.AccessibilityEvent)` for the case of no accessibility delegate been set.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html host` | The View hosting the delegate. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html child` | The child which requests sending the event. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event` | The event to be sent. |

| Returns |
|---|---|
| `boolean` | True if the event should be sent |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/core/view/ViewGroupCompat#onRequestSendAccessibilityEvent(android.view.ViewGroup,android.view.View,android.view.accessibility.AccessibilityEvent)` | ViewGroupCompat#onRequestSendAccessibilityEvent(ViewGroup, View, AccessibilityEvent) |

### performAccessibilityAction

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
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 `https://developer.android.com/reference/androidx/core/view/accessibility/AccessibilityNodeInfoCompat`.

The default implementation behaves as `https://developer.android.com/reference/android/view/View.html#performAccessibilityAction(int, android.os.Bundle)` for the case of no accessibility delegate been set.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host` | View on which to perform the action. |
| `int action` | The action to perform. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/os/Bundle.html args` | Optional action arguments. |

| Returns |
|---|---|
| `boolean` | Whether the action was performed. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#performAccessibilityAction(int, android.os.Bundle)` | View#performAccessibilityAction(int, Bundle) |

### sendAccessibilityEvent

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void sendAccessibilityEvent(@NonNull View host, int eventType)
```

Sends an accessibility event of the given type. If accessibility is not enabled this method has no effect.

The default implementation behaves as `https://developer.android.com/reference/android/view/View.html#sendAccessibilityEvent(int)` for the case of no accessibility delegate been set.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host` | The View hosting the delegate. |
| `int eventType` | The type of the event to send. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#sendAccessibilityEvent(int)` | View#sendAccessibilityEvent(int) |

### sendAccessibilityEventUnchecked

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

```
public void sendAccessibilityEventUnchecked(
    @NonNull View host,
    @NonNull AccessibilityEvent event
)
```

Sends an accessibility event. This method behaves exactly as `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat#sendAccessibilityEvent(android.view.View,int)` but takes as an argument an empty `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html` and does not perform a check whether accessibility is enabled.

The default implementation behaves as `https://developer.android.com/reference/android/view/View.html#sendAccessibilityEventUnchecked(android.view.accessibility.AccessibilityEvent)` for the case of no accessibility delegate been set.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/View.html host` | The View hosting the delegate. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent.html event` | The event to send. |

| See also |
|---|---|
| `https://developer.android.com/reference/android/view/View.html#sendAccessibilityEventUnchecked(android.view.accessibility.AccessibilityEvent)` | View#sendAccessibilityEventUnchecked(AccessibilityEvent) |