【问题标题】:Oreo autofill - how to disable prompt on a field, but still autofill?奥利奥自动填充 - 如何禁用字段提示,但仍然自动填充?
【发布时间】:2018-06-02 20:43:27
【问题描述】:

我有一个信用卡 EditText 字段(全名、到期日期、信用卡号、cvv),这些字段都是在 Android 应用程序中自动填写的。

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

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

到目前为止我所尝试的。

这是我尝试设置的 cvv 字段的示例

importantForAutoFill 为“否”

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

<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" />

【问题讨论】:

  • 查看此链接stackoverflow.com/a/46082925/4938859。我已经尝试过了,它工作正常。对于特定的单个 EditText 检查@Karoly 的答案
  • 我不认为有这个选项。您测试了哪些自动填充服务(因为此行为会因实施而异)?
  • @CommonsWare 我只使用了 Oreo 模拟器加载的默认服务。没有其他的。你有什么建议?
  • @PiyushMalaviya 我认为您的建议更多是关于关闭自动填充。那不是我想要的。我只想控制系统何时显示自动填充提示。你怎么看?
  • 我想你可以提出功能请求。

标签: android android-autofill-manager


【解决方案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);
    }
}

【讨论】:

  • 所以当我点击字段自动填充仍然有效?
  • 正是我需要的 +1
猜你喜欢
  • 1970-01-01
  • 2016-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-22
相关资源
最近更新 更多