Language

CustomDescription.Builder.AddOnClickAction(Int32, IOnClickAction) Method

Definition

Sets an action to be applied to the presentation template when the child view with the given id is clicked.

[Android.Runtime.Register("addOnClickAction", "(ILandroid/service/autofill/OnClickAction;)Landroid/service/autofill/CustomDescription$Builder;", "GetAddOnClickAction_ILandroid_service_autofill_OnClickAction_Handler", ApiSince=29)]
public virtual Android.Service.Autofill.CustomDescription.Builder AddOnClickAction(int id, Android.Service.Autofill.IOnClickAction action);
[<Android.Runtime.Register("addOnClickAction", "(ILandroid/service/autofill/OnClickAction;)Landroid/service/autofill/CustomDescription$Builder;", "GetAddOnClickAction_ILandroid_service_autofill_OnClickAction_Handler", ApiSince=29)>]
abstract member AddOnClickAction : int * Android.Service.Autofill.IOnClickAction -> Android.Service.Autofill.CustomDescription.Builder
override this.AddOnClickAction : int * Android.Service.Autofill.IOnClickAction -> Android.Service.Autofill.CustomDescription.Builder

Parameters

id
Int32

resource id of the child view.

action
IOnClickAction

action to be performed. Must be an an implementation provided by the Android System. This value cannot be null.

Returns

this builder. This value cannot be null.

Attributes

Remarks

Sets an action to be applied to the presentation template when the child view with the given id is clicked.

Typically used when the presentation uses a masked field (like ****) for sensitive fields like passwords or credit cards numbers, but offers a an icon that the user can tap to show the value for that field.

customDescriptionBuilder
  .addChild(R.id.password_plain, new CharSequenceTransformation
     .Builder(passwordId, Pattern.compile("^(.*)$"), "$1").build())
  .addOnClickAction(R.id.showIcon, new VisibilitySetterAction
    .Builder(R.id.hideIcon, View.VISIBLE)
    .setVisibility(R.id.showIcon, View.GONE)
    .setVisibility(R.id.password_plain, View.VISIBLE)
    .setVisibility(R.id.password_masked, View.GONE)
    .build())
  .addOnClickAction(R.id.hideIcon, new VisibilitySetterAction
    .Builder(R.id.showIcon, View.VISIBLE)
    .setVisibility(R.id.hideIcon, View.GONE)
    .setVisibility(R.id.password_masked, View.VISIBLE)
    .setVisibility(R.id.password_plain, View.GONE)
    .build());

Note: Currently only one action can be applied to a child; if this method is called multiple times passing the same id, only the last call will be used.

Android reference for android.service.autofill.CustomDescription.Builder.addOnClickAction.

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