Language

Dataset.Builder.SetField Method

Definition

Overloads

Name Description
SetField(AutofillId, Field)

Sets the value of a field.

SetField(String, Field)

Adds a field to this Dataset with a specific type.

SetField(AutofillId, Field)

Sets the value of a field.

[Android.Runtime.Register("setField", "(Landroid/view/autofill/AutofillId;Landroid/service/autofill/Field;)Landroid/service/autofill/Dataset$Builder;", "", ApiSince=33)]
public Android.Service.Autofill.Dataset.Builder SetField(Android.Views.Autofill.AutofillId id, Android.Service.Autofill.Field? field);
[<Android.Runtime.Register("setField", "(Landroid/view/autofill/AutofillId;Landroid/service/autofill/Field;)Landroid/service/autofill/Dataset$Builder;", "", ApiSince=33)>]
member this.SetField : Android.Views.Autofill.AutofillId * Android.Service.Autofill.Field -> Android.Service.Autofill.Dataset.Builder

Parameters

id
AutofillId

id returned by AssistStructure.ViewNode.getAutofillId(). This value cannot be null.

field
Field

the fill information about the field. This value may be null.

Returns

this builder.

Attributes

Remarks

Sets the value of a field. Before Android 13, this information could be provided using several overloaded setValue(...) methods. This method replaces those with a Builder pattern.

Dataset.Builder dataset = new Dataset.Builder();
if (filter != null) {
    if (presentation != null) {
        if (inlinePresentation != null) {
            dataset.setValue(id, value, filter, presentation, inlinePresentation)
        } else {
            dataset.setValue(id, value, filter, presentation);
        }
    } else {
        dataset.setValue(id, value, filter);
    }
} else {
    if (presentation != null) {
        if (inlinePresentation != null) {
            dataset.setValue(id, value, presentation, inlinePresentation)
        } else {
            dataset.setValue(id, value, presentation);
        }
    } else {
        dataset.setValue(id, value);
    }
}
Field.Builder fieldBuilder = new Field.Builder();
if (value != null) {
    fieldBuilder.setValue(value);
}
if (filter != null) {
    fieldBuilder.setFilter(filter);
}
Presentations.Builder presentationsBuilder = new Presentations.Builder();
if (presentation != null) {
    presentationsBuilder.setMenuPresentation(presentation);
}
if (inlinePresentation != null) {
    presentationsBuilder.setInlinePresentation(inlinePresentation);
}
if (dialogPresentation != null) {
    presentationsBuilder.setDialogPresentation(dialogPresentation);
}
fieldBuilder.setPresentations(presentationsBuilder.build());
dataset.setField(id, fieldBuilder.build());

Android reference for android.service.autofill.Dataset.Builder.setField.

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

SetField(String, Field)

Adds a field to this Dataset with a specific type.

[Android.Runtime.Register("setField", "(Ljava/lang/String;Landroid/service/autofill/Field;)Landroid/service/autofill/Dataset$Builder;", "", ApiSince=34)]
public Android.Service.Autofill.Dataset.Builder SetField(string hint, Android.Service.Autofill.Field field);
[<Android.Runtime.Register("setField", "(Ljava/lang/String;Landroid/service/autofill/Field;)Landroid/service/autofill/Dataset$Builder;", "", ApiSince=34)>]
member this.SetField : string * Android.Service.Autofill.Field -> Android.Service.Autofill.Dataset.Builder

Parameters

hint
String

An autofill hint returned from FillRequest.getHints(). This value cannot be null.

field
Field

the fill information about the field. This value cannot be null.

Returns

this builder. This value cannot be null.

Attributes

Remarks

Adds a field to this Dataset with a specific type. This is used to send back Field information when Autofilling with platform detections is on. Platform detections are on when receiving a populated list from FillRequest#getHints(). Populate every field/type known for this user for this app. For example, if getHints() contains "username" and "password", a new Dataset should be created that calls this method twice, one for the username, then another for the password (assuming the only one credential pair is found for the user). If a user has two credential pairs, then two Datasets should be created, and so on.

Android reference for android.service.autofill.Dataset.Builder.setField.

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