Android Guides | Samples

Android.Views.View.AccessibilityDelegate Class

Developer Guides

java Example

 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());
         }
     });
 }

See Also: View+AccessibilityDelegate

Syntax

[Android.Runtime.Register("android/view/View$AccessibilityDelegate", DoNotGenerateAcw=true)]
public class View.AccessibilityDelegate : Object

Remarks

Developer Guides

java Example

 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());
         }
     });
 }

This class represents a delegate that can be registered in a 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.

For more information about making applications accessible, read the 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 then the minimal API version supported by the application. For example, the method View.OnInitializeAccessibilityNodeInfo(AccessibilityNodeInfo) is not available in API version 4 when the accessibility APIs were first introduced. If a developer would like his 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, he 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 same or higher to the API version that introduced View.OnInitializeAccessibilityNodeInfo(AccessibilityNodeInfo).

Here is an example implementation:

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.

[Android Documentation]

Requirements

Namespace: Android.Views
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 14

The members of Android.Views.View.AccessibilityDelegate are listed below.

See Also: Object

Public Constructors

Protected Constructors

A constructor used when creating managed representations of JNI objects; called by the runtime.

Protected Properties

[read-only]
override
ThresholdClassIntPtr. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.
[read-only]
override
ThresholdTypeType. This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Public Methods

DispatchPopulateAccessibilityEvent(View, AccessibilityEvent) : Boolean
Dispatches an AccessibilityEvent to the host View first and then to its children for adding their text content to the event.
GetAccessibilityNodeProvider(View) : AccessibilityNodeProvider
Gets the provider for managing a virtual view hierarchy rooted at this View and reported to AccessibilityServices that explore the window content.
OnInitializeAccessibilityEvent(View, AccessibilityEvent)
Initializes an AccessibilityEvent with information about the the host View which is the event source.
OnInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo)
Initializes an AccessibilityNodeInfo with information about the host view.
OnPopulateAccessibilityEvent(View, AccessibilityEvent)
Gives a chance to the host View to populate the accessibility event with its text content.
OnRequestSendAccessibilityEvent(ViewGroup, View, AccessibilityEvent) : 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.
PerformAccessibilityAction(View, GlobalAction, Bundle) : Boolean
Performs the specified accessibility action on the view.
SendAccessibilityEvent(View, EventTypes)
Sends an accessibility event of the given type.
SendAccessibilityEventUnchecked(View, AccessibilityEvent)
Sends an accessibility event.