View.DispatchPopulateAccessibilityEvent(AccessibilityEvent) Method
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.
Dispatches an AccessibilityEvent
to the View
to add the text content of the
view and its children.
[Android.Runtime.Register("dispatchPopulateAccessibilityEvent", "(Landroid/view/accessibility/AccessibilityEvent;)Z", "GetDispatchPopulateAccessibilityEvent_Landroid_view_accessibility_AccessibilityEvent_Handler")]
public virtual bool DispatchPopulateAccessibilityEvent (Android.Views.Accessibility.AccessibilityEvent? e);
[<Android.Runtime.Register("dispatchPopulateAccessibilityEvent", "(Landroid/view/accessibility/AccessibilityEvent;)Z", "GetDispatchPopulateAccessibilityEvent_Landroid_view_accessibility_AccessibilityEvent_Handler")>]
abstract member DispatchPopulateAccessibilityEvent : Android.Views.Accessibility.AccessibilityEvent -> bool
override this.DispatchPopulateAccessibilityEvent : Android.Views.Accessibility.AccessibilityEvent -> bool
Parameters
The event.
Returns
True if the event population was completed.
- Attributes
Remarks
Dispatches an AccessibilityEvent
to the View
to add the text content of the view and its children.
<b>Note:</b> This method should only be used with event.setText(). Avoid mutating other event state in this method. In general, put UI metadata in the node for services to easily query. <ul> <li> If you are modifying other event properties, you may be eliminating semantics accessibility services may want. Instead, send a separate event using #sendAccessibilityEvent(int)
and override #onInitializeAccessibilityEvent(AccessibilityEvent)
. </li> <li>If you are checking for type AccessibilityEvent#TYPE_WINDOW_STATE_CHANGED
to generate window/title announcements, you may be causing disruptive announcements (or making no announcements at all). Instead, follow the practices described in View#announceForAccessibility(CharSequence)
. <b>Note:</b> this does not suggest calling announceForAccessibility(), but using the suggestions listed in its documentation. </li> <li>If you are making changes based on the state of accessibility, such as checking for an event type to trigger a UI update, while well-intentioned, you are creating brittle, less well-maintained code that works for some users but not others. Instead, leverage existing code for equitable experiences and less technical debt. See AccessibilityManager#isEnabled()
for an example. </li> </ul>
Note that the event text is populated in a separate dispatch path (#onPopulateAccessibilityEvent(AccessibilityEvent)
) since we add to the event not only the text of the source but also the text of all its descendants.
A typical implementation will call #onPopulateAccessibilityEvent(AccessibilityEvent)
on this view and then call the #dispatchPopulateAccessibilityEvent(AccessibilityEvent)
on each child or the first child that is visible. Override this method if custom population of the event text content is required.
If an AccessibilityDelegate
has been specified via calling #setAccessibilityDelegate(AccessibilityDelegate)
its AccessibilityDelegate#dispatchPopulateAccessibilityEvent(View, AccessibilityEvent)
is responsible for handling this call.
If this view sets #isAccessibilityDataSensitive()
then this view should only append sensitive information to an event that also sets AccessibilityEvent#isAccessibilityDataSensitive()
.
<em>Note:</em> Accessibility events of certain types are not dispatched for populating the event text via this method. For details refer to AccessibilityEvent
.
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.