View.AccessibilityDelegate Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
This class represents a delegate that can be registered in a View
to enhance accessibility support via composition rather via inheritance.
[Android.Runtime.Register("android/view/View$AccessibilityDelegate", DoNotGenerateAcw=true)]
public class View.AccessibilityDelegate : Java.Lang.Object
[<Android.Runtime.Register("android/view/View$AccessibilityDelegate", DoNotGenerateAcw=true)>]
type View.AccessibilityDelegate = class
inherit Object
- Inheritance
- Attributes
Remarks
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.
<div class="special reference"> <h3>Developer Guides</h3>
For more information about making applications accessible, read the Accessibility developer guide.
</div>
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 View#onInitializeAccessibilityNodeInfo(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 View#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo).
Here is an example implementation:
<pre><p> 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()); } }); } </pre></p>
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.
<strong>Note:</strong> On platform versions prior to android.os.Build.VERSION_CODES#M API 23, 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 AccessibilityDelegate#onInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo), as any changes will be overwritten by the host class.
Starting in android.os.Build.VERSION_CODES#M API 23, delegate methods are called after host methods, which all properties to be modified without being overwritten by the host class. "note"> <b>Note:</b> Use a <c>androidx.core.view.AccessibilityDelegateCompat</c> wrapper instead of this class for backwards-compatibility. </aside>
Java documentation for android.view.View.AccessibilityDelegate.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
| Name | Description |
|---|---|
| View.AccessibilityDelegate() |
Initializes a new instance of View.AccessibilityDelegate. |
| View.AccessibilityDelegate(IntPtr, JniHandleOwnership) |
A constructor used when creating managed representations of JNI objects; called by the runtime. |
Properties
| Name | Description |
|---|---|
| Class |
Returns the runtime class of this |
| Handle |
The handle to the underlying Android instance. (Inherited from Object) |
| JniIdentityHashCode |
Gets the identity hash code assigned to this Java peer by the interop runtime. (Inherited from Object) |
| JniPeerMembers |
Gets the JNI peer metadata used by the .NET for Android binding runtime. |
| PeerReference |
Gets the JNI object reference for this Java peer. (Inherited from Object) |
| ThresholdClass |
Gets the JNI class handle used by the .NET for Android binding runtime. |
| ThresholdType |
Gets the managed type used by the .NET for Android binding runtime. |
Methods
| Name | Description |
|---|---|
| AddExtraDataToAccessibilityNodeInfo(View, AccessibilityNodeInfo, String, Bundle) |
Adds requested accessibility data to an accessibility node. |
| Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
| DispatchPopulateAccessibilityEvent(View, AccessibilityEvent) |
Dispatches an |
| Dispose() |
Releases the resources held by this Java peer. (Inherited from Object) |
| Dispose(Boolean) |
Releases the resources held by this Java peer. (Inherited from Object) |
| Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
| GetAccessibilityNodeProvider(View) |
Gets the provider for managing a virtual view hierarchy rooted at this View
and reported to |
| GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
| JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
| Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
| NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
| OnInitializeAccessibilityEvent(View, AccessibilityEvent) |
Initializes an |
| OnInitializeAccessibilityNodeInfo(View, AccessibilityNodeInfo) |
Initializes an |
| OnPopulateAccessibilityEvent(View, AccessibilityEvent) |
Gives a chance to the host View to populate the accessibility event with its text content. |
| OnRequestSendAccessibilityEvent(ViewGroup, View, AccessibilityEvent) |
Called when a child of the host View has requested sending an
|
| PerformAccessibilityAction(View, Action, Bundle) |
Performs the specified accessibility action on the view. |
| PerformAccessibilityAction(View, GlobalAction, Bundle) |
Obsolete.
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. |
| SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
| ToArray<T>() |
Creates a managed array from this Java array wrapper. (Inherited from Object) |
| ToString() |
Returns a string representation of the object. (Inherited from Object) |
| UnregisterFromRuntime() |
Unregisters this Java peer from the interop runtime. (Inherited from Object) |
| Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
| Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
| Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IJavaPeerable.Disposed() |
Notifies the interop runtime that this managed peer has been disposed. (Inherited from Object) |
| IJavaPeerable.DisposeUnlessReferenced() |
Releases this Java peer unless it is retained by another managed reference. (Inherited from Object) |
| IJavaPeerable.Finalized() |
Notifies the interop runtime that this managed peer has been finalized. (Inherited from Object) |
| IJavaPeerable.JniManagedPeerState |
Gets the state that describes the relationship between this managed peer and its JNI reference. (Inherited from Object) |
| IJavaPeerable.SetJniIdentityHashCode(Int32) |
Sets the interop identity hash code for this Java peer. (Inherited from Object) |
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
Sets the managed and JNI peer state for this Java peer. (Inherited from Object) |
| IJavaPeerable.SetPeerReference(JniObjectReference) |
Sets the JNI object reference used by this managed peer. (Inherited from Object) |
Extension Methods
| Name | Description |
|---|---|
| GetJniTypeName(IJavaPeerable) |
Gets the JNI name of the type of the instance |
| JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
| JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
| JavaCast<TResult>(IJavaObject) | |
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |