View.OnPopulateAccessibilityEvent(AccessibilityEvent) Method

Definition

Called from #dispatchPopulateAccessibilityEvent(AccessibilityEvent) giving a chance to this View to populate the accessibility event with its text content.

[Android.Runtime.Register("onPopulateAccessibilityEvent", "(Landroid/view/accessibility/AccessibilityEvent;)V", "GetOnPopulateAccessibilityEvent_Landroid_view_accessibility_AccessibilityEvent_Handler")]
public virtual void OnPopulateAccessibilityEvent (Android.Views.Accessibility.AccessibilityEvent? e);
[<Android.Runtime.Register("onPopulateAccessibilityEvent", "(Landroid/view/accessibility/AccessibilityEvent;)V", "GetOnPopulateAccessibilityEvent_Landroid_view_accessibility_AccessibilityEvent_Handler")>]
abstract member OnPopulateAccessibilityEvent : Android.Views.Accessibility.AccessibilityEvent -> unit
override this.OnPopulateAccessibilityEvent : Android.Views.Accessibility.AccessibilityEvent -> unit

Parameters

e
AccessibilityEvent

The accessibility event which to populate.

Attributes

Remarks

Called from #dispatchPopulateAccessibilityEvent(AccessibilityEvent) giving a chance to this View to populate the accessibility event with its text content.

<b>Note:</b> This method should only be used with event.setText(). Avoid mutating other event state in this method. Instead, follow the practices described in #dispatchPopulateAccessibilityEvent(AccessibilityEvent). In general, put UI metadata in the node for services to easily query, than in transient events.

Example: Adding formatted date string to an accessibility event in addition to the text added by the super implementation:

public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
                super.onPopulateAccessibilityEvent(event);
                final int flags = DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_SHOW_WEEKDAY;
                String selectedDateUtterance = DateUtils.formatDateTime(mContext,
                    mCurrentDate.getTimeInMillis(), flags);
                event.getText().add(selectedDateUtterance);
            }

If an AccessibilityDelegate has been specified via calling #setAccessibilityDelegate(AccessibilityDelegate) its AccessibilityDelegate#onPopulateAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.

<strong>Note:</strong> Always call the super implementation before adding information to the event, in case the default implementation has basic information to add.

Java documentation for android.view.View.onPopulateAccessibilityEvent(android.view.accessibility.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.

Applies to

See also