【发布时间】:2021-07-02 11:14:55
【问题描述】:
我对@987654321@ 有疑问
当我想设置一些视图时,我收到一个消息问题"Missing autofillHints attribute"
有什么建议么?
【问题讨论】:
-
tools:ignore="Autofill"是目前唯一可以忽略的方法。
标签: android
我对@987654321@ 有疑问
当我想设置一些视图时,我收到一个消息问题"Missing autofillHints attribute"
有什么建议么?
【问题讨论】:
tools:ignore="Autofill" 是目前唯一可以忽略的方法。
标签: android
也许您正在使用EditText。 autofillHints 在 API 26 及更高版本中用于填充空的 EditTexts,它实际上是在建议应该在其中放置哪种类型的内容。
只需添加:
android:autofillHints="username" // the type of content you want
发送至您的EditText,警告将消失。
您可以使用新的
android:autofillHints属性来告诉autofill您期望的内容类型,以及android:importantForAutofill告诉autofill您想要哪些视图(或 不想)被填满。
阅读: https://medium.com/@bherbst/getting-androids-autofill-to-work-for-you-21435debea1
还有这个: https://developer.android.com/guide/topics/text/autofill-services
编辑:
但是你可以设置:
android:importantForAutofill="no"
向组件告诉填充和消除错误并不重要。
【讨论】:
autofillHints
minSdk>=26 .
如果你不想要自动填充提示,应该使用android:importantForAutofill=no
<EditText
android:importantForAutofill="no"/>
minSdk
添加 android:importantForAutofill 然后 tools:targetApi 使 IDE 不会出现有关 API 级别的警告
<EditText
android:importantForAutofill="no"
tools:targetApi="o"
/>
autofillHints
即使我们没有设置autofillHints 属性,自动填充服务也会默认启用。指定一个 autofillHints 将帮助自动填充服务像我们预期的那样更好地工作。见documents here
minSdk>=26
只需要添加android:autofillHints="{a contant value}"(例如:"android:autofillHints="password")(使用来自here的常量)
minSdk,添加tools:targetApi让IDE不出现这个警告
<EditText
android:autofillHints="emailAddress"
tools:targetApi="o"/>
注意
autofillHints 和 importantForAutofill 仅在 API 26 及更高版本中使用,但我们仍然可以在 API you can see in this answer)(它不会崩溃,但当然它对 API 没有任何影响)
tool:... 只是用来让 IDE 不警告,它不会在应用程序运行时产生任何影响,所以tools:ignore="Autofill 不会帮你隐藏自动填充提示
【讨论】:
android:autoFillHints 常量是 emailAddress 而不仅仅是 email。
您需要在 strings.xml 文件中启用字符串文本,例如:
<string name="editText2">Name</string>.
然后你需要activity_mail.xml - 然后启用 autofillhint 活动,使用:
android:hint="@string/editText2"
【讨论】: