Share via


View.OnProvideAutofillVirtualStructure(ViewStructure, AutofillFlags) Method

Definition

Populates a ViewStructure containing virtual children to fullfil an autofill request.

[Android.Runtime.Register("onProvideAutofillVirtualStructure", "(Landroid/view/ViewStructure;I)V", "GetOnProvideAutofillVirtualStructure_Landroid_view_ViewStructure_IHandler", ApiSince=26)]
public virtual void OnProvideAutofillVirtualStructure (Android.Views.ViewStructure? structure, Android.Views.AutofillFlags flags);
[<Android.Runtime.Register("onProvideAutofillVirtualStructure", "(Landroid/view/ViewStructure;I)V", "GetOnProvideAutofillVirtualStructure_Landroid_view_ViewStructure_IHandler", ApiSince=26)>]
abstract member OnProvideAutofillVirtualStructure : Android.Views.ViewStructure * Android.Views.AutofillFlags -> unit
override this.OnProvideAutofillVirtualStructure : Android.Views.ViewStructure * Android.Views.AutofillFlags -> unit

Parameters

structure
ViewStructure

fill in with virtual children data for autofill purposes.

flags
AutofillFlags

optional flags.

Attributes

Remarks

Populates a ViewStructure containing virtual children to fullfil an autofill request.

This method should be used when the view manages a virtual structure under this view. For example, a view that draws input fields using #draw(Canvas).

When implementing this method, subclasses must follow the rules below:

<ul> <li>Add virtual children by calling the ViewStructure#newChild(int) or ViewStructure#asyncNewChild(int) methods, where the id is an unique id identifying the children in the virtual structure. <li>The children hierarchy can have multiple levels if necessary, but ideally it should exclude intermediate levels that are irrelevant for autofill; that would improve the autofill performance. <li>Also implement #autofill(SparseArray) to autofill the virtual children. <li>Set the autofill properties of the child structure as defined by #onProvideAutofillStructure(ViewStructure, int), using ViewStructure#setAutofillId(AutofillId, int) to set its autofill id. <li>Call android.view.autofill.AutofillManager#notifyViewEntered(View, int, Rect) and/or android.view.autofill.AutofillManager#notifyViewExited(View, int) when the focused virtual child changed. <li>Override #isVisibleToUserForAutofill(int) to allow the platform to query whether a given virtual view is visible to the user in order to support triggering save when all views of interest go away. <li>Call android.view.autofill.AutofillManager#notifyValueChanged(View, int, AutofillValue) when the value of a virtual child changed. <li>Call android.view.autofill.AutofillManager#notifyViewVisibilityChanged(View, int, boolean) when the visibility of a virtual child changed. <li>Call android.view.autofill.AutofillManager#notifyViewClicked(View, int) when a virtual child is clicked. <li>Call AutofillManager#commit() when the autofill context of the view structure changed and the current context should be committed (for example, when the user tapped a SUBMIT button in an HTML page). <li>Call AutofillManager#cancel() when the autofill context of the view structure changed and the current context should be canceled (for example, when the user tapped a CANCEL button in an HTML page). <li>Provide ways for users to manually request autofill by calling AutofillManager#requestAutofill(View, int, Rect). <li>The left and top values set in ViewStructure#setDimens(int, int, int, int, int, int) must be relative to the next ViewGroup#isImportantForAutofill() predecessor view included in the structure. </ul>

Views with virtual children support the Autofill Framework mainly by: <ul> <li>Providing the metadata defining what the virtual children mean and how they can be autofilled. <li>Implementing the methods that autofill the virtual children. </ul>

This method is responsible for the former; #autofill(SparseArray) is responsible for the latter.

Java documentation for android.view.View.onProvideAutofillVirtualStructure(android.view.ViewStructure, int).

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