共用方式為


View.AccessibilityDelegate Class

Definition

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
View.AccessibilityDelegate
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.

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

View.AccessibilityDelegate()
View.AccessibilityDelegate(IntPtr, JniHandleOwnership)

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

Properties

Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode (Inherited from Object)
JniPeerMembers
PeerReference (Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

Methods

AddExtraDataToAccessibilityNodeInfo(View, AccessibilityNodeInfo, String, Bundle)

Adds extra data to an AccessibilityNodeInfo based on an explicit request for the additional data.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
DispatchPopulateAccessibilityEvent(View, AccessibilityEvent)

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

Dispose() (Inherited from Object)
Dispose(Boolean) (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 android.accessibilityservice.AccessibilityServices that explore the window content.

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 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)

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, 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>() (Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime() (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

IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
GetJniTypeName(IJavaPeerable)

Applies to