Partager via


View.Autofill Method

Definition

Overloads

Autofill(SparseArray)

Automatically fills the content of the virtual children within this view.

Autofill(AutofillValue)

Automatically fills the content of this view with the value.

Autofill(SparseArray)

Automatically fills the content of the virtual children within this view.

[Android.Runtime.Register("autofill", "(Landroid/util/SparseArray;)V", "GetAutofill_Landroid_util_SparseArray_Handler", ApiSince=26)]
public virtual void Autofill (Android.Util.SparseArray values);
[<Android.Runtime.Register("autofill", "(Landroid/util/SparseArray;)V", "GetAutofill_Landroid_util_SparseArray_Handler", ApiSince=26)>]
abstract member Autofill : Android.Util.SparseArray -> unit
override this.Autofill : Android.Util.SparseArray -> unit

Parameters

values
SparseArray

map of values to be autofilled, keyed by virtual child id.

Attributes

Remarks

Automatically fills the content of the virtual children within this view.

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>

#onProvideAutofillVirtualStructure(ViewStructure, int) is responsible for the former, this method is responsible for the latter - see #autofill(AutofillValue) and #onProvideAutofillVirtualStructure(ViewStructure, int) for more info about autofill.

If a child value is updated asynchronously, the next call to AutofillManager#notifyValueChanged(View, int, AutofillValue) must happen <b>after</b> the value was changed to the autofilled value. If not, the child will not be considered autofilled.

<b>Note:</b> To indicate that a virtual view was autofilled, ?android:attr/autofilledHighlight should be drawn over it until the data changes.

Java documentation for android.view.View.autofill(android.util.SparseArray<android.view.autofill.AutofillValue>).

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

Autofill(AutofillValue)

Automatically fills the content of this view with the value.

[Android.Runtime.Register("autofill", "(Landroid/view/autofill/AutofillValue;)V", "GetAutofill_Landroid_view_autofill_AutofillValue_Handler", ApiSince=26)]
public virtual void Autofill (Android.Views.Autofill.AutofillValue? value);
[<Android.Runtime.Register("autofill", "(Landroid/view/autofill/AutofillValue;)V", "GetAutofill_Landroid_view_autofill_AutofillValue_Handler", ApiSince=26)>]
abstract member Autofill : Android.Views.Autofill.AutofillValue -> unit
override this.Autofill : Android.Views.Autofill.AutofillValue -> unit

Parameters

value
AutofillValue

value to be autofilled.

Attributes

Remarks

Automatically fills the content of this view with the value.

Views support the Autofill Framework mainly by: <ul> <li>Providing the metadata defining what the view means and how it can be autofilled. <li>Implementing the methods that autofill the view. </ul>

#onProvideAutofillStructure(ViewStructure, int) is responsible for the former, this method is responsible for latter.

This method does nothing by default, but when overridden it typically: <ol> <li>Checks if the provided value matches the expected type (which is defined by #getAutofillType()). <li>Checks if the view is editable - if it isn't, it should return right away. <li>Call the proper getter method on AutofillValue to fetch the actual value. <li>Pass the actual value to the equivalent setter in the view. </ol>

For example, a text-field view could implement the method this way:

&#64;Override
            public void autofill(AutofillValue value) {
              if (!value.isText() || !this.isEditable()) {
                 return;
              }
              CharSequence text = value.getTextValue();
              if (text != null) {
                this.setText(text);
              }
            }

If the value is updated asynchronously, the next call to AutofillManager#notifyValueChanged(View) must happen <b>after</b> the value was changed to the autofilled value. If not, the view will not be considered autofilled.

<b>Note:</b> After this method is called, the value returned by #getAutofillValue() must be equal to the value passed to it, otherwise the view will not be highlighted as autofilled.

Java documentation for android.view.View.autofill(android.view.autofill.AutofillValue).

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