我有一个问题,Palette -> Text
当我想设置一些视图时,收到消息问题有"Missing autofillHints attribute"
什么建议吗?
Answers:
也许您正在使用EditText。autofillHints在API 26及更高版本中使用来填充empty EditTexts,它实际上是建议应在其中放置哪种类型的内容。
只需添加:
android:autofillHints="username" // the type of content you want
给您EditText和警告将消失。
您可以使用new
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"
对组件来说,填充并消除错误并不重要。
autofillHintsminSdk> = 26。
android:importantForAutofill=no如果您不想要自动填充提示,则应使用
<EditText
android:importantForAutofill="no"/>
minSdk <26
1)使用 tools:ignore="Autofill"
<EditText
tools:ignore="Autofill"/>
2)或添加android:importantForAutofill然后tools:targetApi使IDE不会发出有关API级别的警告
<EditText
android:importantForAutofill="no"
tools:targetApi="o"
/>
autofillHintsminSdk> = 26
只需添加android:autofillHints="{a contant value}"(例如:"android:autofillHints="password")(从此处使用常量)
minSdk <26,添加tools:targetApi使IDE不再显示此警告
<EditText
android:autofillHints="email"
tools:targetApi="o"/>
注意
autofillHints并且importantForAutofill仅在API 26及更高版本中使用,但我们仍然可以在API <26中使用它而不会崩溃(您可以在此答案中看到)(它不会崩溃,但在API <26中当然没有任何作用)
tool:... 仅用于使IDE不发出警告,在应用程序运行时不会产生任何影响
android:autoFillHints一个电子邮件地址常数emailAddress,而不仅仅是email。
您需要使用strings.xml文件并在其中启用字符串文本,例如:
<string name="editText2">Name</string>.
那么您需要activity_mail.xml-通过使用以下命令在其中启用autofillhint活动:
android:hint="@string/editText2"
tools:ignore="Autofill"只是暂时忽略的方法。