andoridはautofillサービスおよびAutofillHintsおよびsetImportantForAutofill関連の使用方法を構築します.
Autofillサービスを構築表示リストにデータを埋め込むには、appがAutofillServiceを継承するときにonFillRequest()データ要求を書き換えるときにデータをロードする必要があります.ここではonFillRequestについて説明します.
次に、EditTextに関するいくつかの関連使用とデータについて説明します.1.AutofillHintsとsetImportantForAutofill概要-view上のAutofillの2つのキープロパティautofillHintsとsetImportantForAutofill、autofillHints:自動入力をクリックすると、プロンプトリストが表示され、処理しないか、属性を追加しないとプロンプトリストは表示されません.setImportantForAutofill:このプロパティは、主にEdiTextやTextViewなどのビューを開くときに、このプロパティを使用して設定されます.自動ポップアップまたは手動ポップアップ、activity_layout.xml定義;
MainActivity.JAva定義
view.settofilHints()メソッドを使用してタグを設定します.関連する値は、Viewクラス(api 26以降)で定義されているいくつかのStringタイプ定数です.
setImportantForAutofill()関連値はすべてViewクラス(api 26バージョン以上)です.
android N新規API Autofill
公式Demo;https://github.com/googlesamples/android-AutofillFramework https://download.csdn.net/download/xiao_yuanjl/10862116
public class MyAutofillService extends AutofillService{
.....
@Override
public void onFillRequest(FillRequest request, CancellationSignal cancellationSignal,
FillCallback callback) {
// ;
FillResponse.Builder response = new FillResponse.Builder();
for (int i = 1; i <= NUMBER_DATASETS; i++) {
Dataset.Builder dataset = new Dataset.Builder();
// RemoteViews. xml ;
RemoteView presentation =new RemoteViews(getApplicationContext().
.packageName,R.layout.multidataset_service_list_item);
// Item ,remoteViewsText;
presentation.setTextViewText(R.id.text, text);
// data ;
response.addDataset(dataset.build());
}
// android ,
callback.onSuccess(response.build());
}
}
次に、EditTextに関するいくつかの関連使用とデータについて説明します.1.AutofillHintsとsetImportantForAutofill概要-view上のAutofillの2つのキープロパティautofillHintsとsetImportantForAutofill、autofillHints:自動入力をクリックすると、プロンプトリストが表示され、処理しないか、属性を追加しないとプロンプトリストは表示されません.setImportantForAutofill:このプロパティは、主にEdiTextやTextViewなどのビューを開くときに、このプロパティを使用して設定されます.自動ポップアップまたは手動ポップアップ、activity_layout.xml定義;
MainActivity.JAva定義
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText et=findViewById(R.id.username);
//
et.setAutofillHints(View.AUTOFILL_HINT_PASSWORD);
//
et.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO);
}
}
view.settofilHints()メソッドを使用してタグを設定します.関連する値は、Viewクラス(api 26以降)で定義されているいくつかのStringタイプ定数です.
AUTOFILL_HINT_NAME
AUTOFILL_HINT_PASSWORD
AUTOFILL_HINT_PHONE
AUTOFILL_HINT_EMAIL_ADDRESS
AUTOFILL_HINT_POSTAL_CODE
AUTOFILL_HINT_POSTAL_ADDRESS
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH
AUTOFILL_HINT_CREDIT_CARD_NUMBER
AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR
AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY
setImportantForAutofill()関連値はすべてViewクラス(api 26バージョン以上)です.
//Automatically determine whether a view is important for autofill.
public static final int IMPORTANT_FOR_AUTOFILL_AUTO = 0x0;
//The view is important for autofill, but its children (if any) will not be traversed.
public static final int IMPORTANT_FOR_AUTOFILL_YES = 0x1;
//The view is not important for autofill, but its children (if any) will be traversed.
public static final int IMPORTANT_FOR_AUTOFILL_NO = 0x2;
//The view is important for autofill, but its children (if any) will not be traversed.
public static final int IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS = 0x4;
//The view is not important for autofill, and its children (if any) will not be traversed.
public static final int IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS = 0x8;
android N新規API Autofill
公式Demo;https://github.com/googlesamples/android-AutofillFramework https://download.csdn.net/download/xiao_yuanjl/10862116