Udostępnij za pośrednictwem


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. While this method is free to modify event attributes other than text content, doing so should normally be performed in #onInitializeAccessibilityEvent(AccessibilityEvent).

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.

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

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