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
觸發更新的條件。 這個值不可能為零值。
- updates
- BatchUpdates
當條件滿足時,將對範本呈現套用的動作。 這個值不可能為零值。
傳回
這個建築商。 這個值不可能為零值。
- 屬性
備註
當條件滿足時,透過一系列遠端檢視操作更新呈現模板。 這允許動態自訂由自動填充服務控制的存檔介面部分。 這種動態自訂是基於目標視圖的內容。
更新會依照在子視圖轉換後加入的順序套用。
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();
另一種方法是先加入一個子節點,再套用轉換。
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
本頁部分內容為基於 Open Source Project 所創建與分享的作品,並依授權條款所描述的使用進行修改。