奥利奥自动填充 - 如何禁用字段上的提示,但仍然自动填充?

时间:2017-12-20 10:09:40

标签: android android-autofill-manager

我有一个信用卡EditText字段(全名,有效期,信用卡号,cvv),这些字段都在Android应用程序中自动填充。

问题是自动填充提示出现在每个字段上。我只想在用户点击信用卡字段时显示自动填充。例如,如果用户单击cvv或到期日期,则不应提示自动填充。

关键是我仍然希望所有字段都是自动填充,但我只是不希望提示出现在所有字段上。

到目前为止我的尝试。

这是我尝试设置

的cvv字段的示例
  

importantForAuto填写“否”

但这会使该字段完全被忽略。我只是不希望出现提示:

<EditText
                        android:id="@+id/et_cc_cvv"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:autofillHints="creditCardSecurityCode"
                        android:importantForAutofill="no"
                        android:drawableRight="@drawable/question_icon"
                        android:hint="@string/cvv"
                        android:imeOptions="actionDone"
                        android:inputType="number" />

1 个答案:

答案 0 :(得分:1)

@Override
public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   disableAutoFill();
}


public void disableAutoFill() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        getWindow().getDecorView().setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
    }
}