Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/view/View.AccessibilityDelegate#pubctors) \| [Methods](https://developer.android.com/reference/android/view/View.AccessibilityDelegate#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/View.AccessibilityDelegate#inhmethods)

# View.AccessibilityDelegate

*** ** * ** ***

` public static class View.AccessibilityDelegate `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.View.AccessibilityDelegate |

<br />

*** ** * ** ***

<br />

This class represents a delegate that can be registered in a `https://developer.android.com/reference/android/view/View` to enhance accessibility support via composition rather via inheritance. It is specifically targeted to widget developers that extend basic View classes i.e. classes in package android.view, that would like their applications to be backwards compatible.

### Developer Guides

For more information about making applications accessible, read the [Accessibility](https://developer.android.com/guide/topics/ui/accessibility) developer guide.

A scenario in which a developer would like to use an accessibility delegate is overriding a method introduced in a later API version than the minimal API version supported by the application. For example, the method `https://developer.android.com/reference/android/view/View#onInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)` is not available in API version 4 when the accessibility APIs were first introduced. If a developer would like their application to run on API version 4 devices (assuming all other APIs used by the application are version 4 or lower) and take advantage of this method, instead of overriding the method which would break the application's backwards compatibility, they can override the corresponding method in this delegate and register the delegate in the target View if the API version of the system is high enough, i.e. the API version is the same as or higher than the API version that introduced `https://developer.android.com/reference/android/view/View#onInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)`.

Here is an example implementation:
`

`

    `
    if (Build.VERSION.SDK_INT >= 14) {
        // If the API version is equal of higher than the version in
        // which onInitializeAccessibilityNodeInfo was introduced we
        // register a delegate with a customized implementation.
        View view = findViewById(R.id.view_id);
        view.setAccessibilityDelegate(new AccessibilityDelegate() {
            public void onInitializeAccessibilityNodeInfo(View host,
                    AccessibilityNodeInfo info) {
                // Let the default implementation populate the info.
                super.onInitializeAccessibilityNodeInfo(host, info);
                // Set some other information.
                info.setEnabled(host.isEnabled());
            }
        });
    }
    `

<br />

This delegate contains methods that correspond to the accessibility methods in View. If a delegate has been specified the implementation in View hands off handling to the corresponding method in this delegate. The default implementation the delegate methods behaves exactly as the corresponding method in View for the case of no accessibility delegate been set. Hence, to customize the behavior of a View method, clients can override only the corresponding delegate method without altering the behavior of the rest accessibility related methods of the host view.

**Note:** On platform versions prior to `https://developer.android.com/reference/android/os/Build.VERSION_CODES#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/android/view/View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(android.view.View,%20android.view.accessibility.AccessibilityNodeInfo)`, as any changes will be overwritten by the host class.

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

> [!NOTE]
> **Note:** Use a `https://developer.android.com/reference/androidx/core/view/AccessibilityDelegateCompat.html` wrapper instead of this class for backwards-compatibility.

<br />

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#AccessibilityDelegate()() ` |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#addExtraDataToAccessibilityNodeInfo(android.view.View,%20android.view.accessibility.AccessibilityNodeInfo,%20java.lang.String,%20android.os.Bundle)(https://developer.android.com/reference/android/view/View host, https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo info, https://developer.android.com/reference/java/lang/String extraDataKey, https://developer.android.com/reference/android/os/Bundle arguments) ` Adds extra data to an `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo` based on an explicit request for the additional data. |
| ` boolean` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#dispatchPopulateAccessibilityEvent(android.view.View,%20android.view.accessibility.AccessibilityEvent)(https://developer.android.com/reference/android/view/View host, https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent event) ` Dispatches an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent` to the host `https://developer.android.com/reference/android/view/View` first and then to its children for adding their text content to the event. |
| ` https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeProvider` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#getAccessibilityNodeProvider(android.view.View)(https://developer.android.com/reference/android/view/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`s that explore the window content. |
| ` void` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#onInitializeAccessibilityEvent(android.view.View,%20android.view.accessibility.AccessibilityEvent)(https://developer.android.com/reference/android/view/View host, https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent event) ` Initializes an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent` with information about the the host View which is the event source. |
| ` void` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#onInitializeAccessibilityNodeInfo(android.view.View,%20android.view.accessibility.AccessibilityNodeInfo)(https://developer.android.com/reference/android/view/View host, https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo info) ` Initializes an `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo` with information about the host view. |
| ` void` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#onPopulateAccessibilityEvent(android.view.View,%20android.view.accessibility.AccessibilityEvent)(https://developer.android.com/reference/android/view/View host, https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent event) ` Gives a chance to the host View to populate the accessibility event with its text content. |
| ` boolean` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#onRequestSendAccessibilityEvent(android.view.ViewGroup,%20android.view.View,%20android.view.accessibility.AccessibilityEvent)(https://developer.android.com/reference/android/view/ViewGroup host, https://developer.android.com/reference/android/view/View child, https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent event) ` Called when a child of the host View has requested sending an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent` and gives an opportunity to the parent (the host) to augment the event. |
| ` boolean` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#performAccessibilityAction(android.view.View,%20int,%20android.os.Bundle)(https://developer.android.com/reference/android/view/View host, int action, https://developer.android.com/reference/android/os/Bundle args) ` Performs the specified accessibility action on the view. |
| ` void` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#sendAccessibilityEvent(android.view.View,%20int)(https://developer.android.com/reference/android/view/View host, int eventType) ` Sends an accessibility event of the given type. |
| ` void` | ` https://developer.android.com/reference/android/view/View.AccessibilityDelegate#sendAccessibilityEventUnchecked(android.view.View,%20android.view.accessibility.AccessibilityEvent)(https://developer.android.com/reference/android/view/View host, https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent event) ` Sends an accessibility event. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### AccessibilityDelegate

```
public AccessibilityDelegate ()
```

<br />

<br />

## Public methods

### addExtraDataToAccessibilityNodeInfo

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void addExtraDataToAccessibilityNodeInfo (View host, 
                AccessibilityNodeInfo info, 
                String extraDataKey, 
                Bundle arguments)
```

Adds extra data to an `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo` based on an explicit request for the additional data.

This method only needs to be implemented if the View offers to provide additional data.

The default implementation behaves as `https://developer.android.com/reference/android/view/View#addExtraDataToAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo,%20java.lang.String,%20android.os.Bundle)` for the case where no accessibility delegate is set.

<br />

<br />

| Parameters ||
|---|---|
| `host` | `View`: The View hosting the delegate. Never `null`. <br /> |
| `info` | `AccessibilityNodeInfo`: The info to which to add the extra data. Never `null`. <br /> |
| `extraDataKey` | `String`: A key specifying the type of extra data to add to the info. The extra data should be added to the `https://developer.android.com/reference/android/os/Bundle` returned by the info's `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo#getExtras()` method. Never `null`. <br /> |
| `arguments` | `Bundle`: A `https://developer.android.com/reference/android/os/Bundle` holding any arguments relevant for this request. May be `null` if the if the service provided no arguments. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo#setAvailableExtraData(java.util.List<java.lang.String>)`

### dispatchPopulateAccessibilityEvent

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

Dispatches an `https://developer.android.com/reference/android/view/accessibility/AccessibilityEvent` to the host `https://developer.android.com/reference/android/view/View` 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#dispatchPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent)` for the case of no accessibility delegate been set.

<br />

<br />

| Parameters ||
|---|---|
| `host` | `View`: The View hosting the delegate. This value cannot be `null`. <br /> |
| `event` | `AccessibilityEvent`: The event. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | True if the event population was completed. <br /> |

**See also:**

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

### getAccessibilityNodeProvider

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public AccessibilityNodeProvider getAccessibilityNodeProvider (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`s that explore the window content.

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

<br />

<br />

| Parameters ||
|---|---|
| `host` | `View`: This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeProvider` | The provider. This value may be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeProvider`

### onInitializeAccessibilityEvent

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

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

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

<br />

<br />

| Parameters ||
|---|---|
| `host` | `View`: The View hosting the delegate. This value cannot be `null`. <br /> |
| `event` | `AccessibilityEvent`: The event to initialize. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/View#onInitializeAccessibilityEvent(android.view.accessibility.AccessibilityEvent)`

### onInitializeAccessibilityNodeInfo

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onInitializeAccessibilityNodeInfo (View host, 
                AccessibilityNodeInfo info)
```

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

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

<br />

<br />

| Parameters ||
|---|---|
| `host` | `View`: The View hosting the delegate. This value cannot be `null`. <br /> |
| `info` | `AccessibilityNodeInfo`: The instance to initialize. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/View#onInitializeAccessibilityNodeInfo(android.view.accessibility.AccessibilityNodeInfo)`

### onPopulateAccessibilityEvent

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void onPopulateAccessibilityEvent (View host, 
                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/android/view/View#onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent)` for the case of no accessibility delegate been set.

<br />

<br />

| Parameters ||
|---|---|
| `host` | `View`: The View hosting the delegate. This value cannot be `null`. <br /> |
| `event` | `AccessibilityEvent`: The accessibility event which to populate. This value cannot be `null`. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/View#onPopulateAccessibilityEvent(android.view.accessibility.AccessibilityEvent)`

### onRequestSendAccessibilityEvent

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

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

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

<br />

<br />

| Parameters ||
|---|---|
| `host` | `ViewGroup`: The View hosting the delegate. This value cannot be `null`. <br /> |
| `child` | `View`: The child which requests sending the event. This value cannot be `null`. <br /> |
| `event` | `AccessibilityEvent`: The event to be sent. This value cannot be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | True if the event should be sent <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/ViewGroup#onRequestSendAccessibilityEvent(android.view.View,%20android.view.accessibility.AccessibilityEvent)`

### performAccessibilityAction

Added in [API level 16](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean performAccessibilityAction (View host, 
                int action, 
                Bundle args)
```

Performs the specified accessibility action on the view. For possible accessibility actions look at `https://developer.android.com/reference/android/view/accessibility/AccessibilityNodeInfo`.

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

<br />

<br />

| Parameters ||
|---|---|
| `host` | `View`: This value cannot be `null`. <br /> |
| `action` | `int`: The action to perform. <br /> |
| `args` | `Bundle`: This value may be `null`. <br /> |

| Returns ||
|---|---|
| `boolean` | Whether the action was performed. <br /> |

**See also:**

- `https://developer.android.com/reference/android/view/View#performAccessibilityAction(int,%20android.os.Bundle)`

### sendAccessibilityEvent

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void sendAccessibilityEvent (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#sendAccessibilityEvent(int)` for the case of no accessibility delegate been set.

<br />

<br />

| Parameters ||
|---|---|
| `host` | `View`: The View hosting the delegate. This value cannot be `null`. <br /> |
| `eventType` | `int`: The type of the event to send. <br /> |

**See also:**

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

### sendAccessibilityEventUnchecked

Added in [API level 14](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

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

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

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

<br />

<br />

| Parameters ||
|---|---|
| `host` | `View`: The View hosting the delegate. This value cannot be `null`. <br /> |
| `event` | `AccessibilityEvent`: The event to send. This value cannot be `null`. <br /> |

**See also:**

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