CustomDescription.Builder.BatchUpdate(IValidator, BatchUpdates) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
通过应用一系列远程视图操作,更新满足条件的演示文稿模板。
[Android.Runtime.Register("batchUpdate", "(Landroid/service/autofill/Validator;Landroid/service/autofill/BatchUpdates;)Landroid/service/autofill/CustomDescription$Builder;", "GetBatchUpdate_Landroid_service_autofill_Validator_Landroid_service_autofill_BatchUpdates_Handler", ApiSince=28)]
public virtual Android.Service.Autofill.CustomDescription.Builder BatchUpdate(Android.Service.Autofill.IValidator condition, Android.Service.Autofill.BatchUpdates updates);
[<Android.Runtime.Register("batchUpdate", "(Landroid/service/autofill/Validator;Landroid/service/autofill/BatchUpdates;)Landroid/service/autofill/CustomDescription$Builder;", "GetBatchUpdate_Landroid_service_autofill_Validator_Landroid_service_autofill_BatchUpdates_Handler", ApiSince=28)>]
abstract member BatchUpdate : Android.Service.Autofill.IValidator * Android.Service.Autofill.BatchUpdates -> Android.Service.Autofill.CustomDescription.Builder
override this.BatchUpdate : Android.Service.Autofill.IValidator * Android.Service.Autofill.BatchUpdates -> Android.Service.Autofill.CustomDescription.Builder
参数
- condition
- IValidator
用于触发更新的条件。 此值不能为 null。
- updates
- BatchUpdates
满足条件时要应用于模板演示文稿的操作。 此值不能为 null。
返回
此生成器。 此值不能为 null。
- 特性
注解
通过应用一系列远程视图操作,更新满足条件的演示文稿模板。 这允许动态自定义由自动填充服务控制的保存 UI 部分。 此类动态自定义基于目标视图的内容。
在将转换应用到子视图后,更新将按添加的顺序应用。
例如,若要使子视图在字段不为空时可见:
RemoteViews template = new RemoteViews(pgkName, R.layout.my_full_template);
Pattern notEmptyPattern = Pattern.compile(".+");
Validator hasAddress = new RegexValidator(addressAutofillId, notEmptyPattern);
Validator hasCcNumber = new RegexValidator(ccNumberAutofillId, notEmptyPattern);
RemoteViews addressUpdates = new RemoteViews(pgkName, R.layout.my_full_template)
addressUpdates.setViewVisibility(R.id.address, View.VISIBLE);
// Make address visible
BatchUpdates addressBatchUpdates = new BatchUpdates.Builder()
.updateTemplate(addressUpdates)
.build();
RemoteViews ccUpdates = new RemoteViews(pgkName, R.layout.my_full_template)
ccUpdates.setViewVisibility(R.id.cc_number, View.VISIBLE);
// Mask credit card number (as .....LAST_4_DIGITS) and make it visible
BatchUpdates ccBatchUpdates = new BatchUpdates.Builder()
.updateTemplate(ccUpdates)
.transformChild(R.id.templateCcNumber, new CharSequenceTransformation
.Builder(ccNumberId, Pattern.compile("^.*(\\d\\d\\d\\d)$"), "...$1")
.build())
.build();
CustomDescription customDescription = new CustomDescription.Builder(template)
.batchUpdate(hasAddress, addressBatchUpdates)
.batchUpdate(hasCcNumber, ccBatchUpdates)
.build();
另一种方法是先添加子级,然后应用转换。 Example:
RemoteViews template = new RemoteViews(pgkName, R.layout.my_base_template);
RemoteViews addressPresentation = new RemoteViews(pgkName, R.layout.address)
RemoteViews addressUpdates = new RemoteViews(pgkName, R.layout.my_template)
addressUpdates.addView(R.id.parentId, addressPresentation);
BatchUpdates addressBatchUpdates = new BatchUpdates.Builder()
.updateTemplate(addressUpdates)
.build();
RemoteViews ccPresentation = new RemoteViews(pgkName, R.layout.cc)
RemoteViews ccUpdates = new RemoteViews(pgkName, R.layout.my_template)
ccUpdates.addView(R.id.parentId, ccPresentation);
BatchUpdates ccBatchUpdates = new BatchUpdates.Builder()
.updateTemplate(ccUpdates)
.transformChild(R.id.templateCcNumber, new CharSequenceTransformation
.Builder(ccNumberId, Pattern.compile("^.*(\\d\\d\\d\\d)$"), "...$1")
.build())
.build();
CustomDescription customDescription = new CustomDescription.Builder(template)
.batchUpdate(hasAddress, addressBatchUpdates)
.batchUpdate(hasCcNumber, ccBatchUpdates)
.build();
Android 参考。android.service.autofill.CustomDescription.Builder.batchUpdate
本页的某些部分是根据 Android 开放源代码项目创建和共享的工作进行的修改,并根据 Creative Commons 2.5 属性许可证中所述的术语使用。