“缺少autofillHints属性”


92

我有一个问题,Palette -> Text
当我想设置一些视图时,收到消息问题有"Missing autofillHints attribute"
什么建议吗?


1
tools:ignore="Autofill"只是暂时忽略的方法。
Pratik Butani

Answers:


93

也许您正在使用EditTextautofillHints在API 26及更高版本中使用来填充empty EditTexts,它实际上是建议应在其中放置哪种类型的内容。

只需添加:

android:autofillHints="username" // the type of content you want

给您EditText和警告将消失。

您可以使用newandroid: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"

对组件来说,填充并消除错误并不重要。


再次出现错误:(“缺少可访问性标签”“旧版本未使用属性”
塞巴斯蒂安

我可以看截图吗?此后应该消失。
ʍѳђઽ9ท

再次出现错误:(““缺少可访问性标签”“在旧版本中未使用属性”
Sebastian

我是这里的新手,所以我还无法发送图片:(
塞巴斯蒂安

1
注意:“ importantForAutofill”仅在API级别26和更高级别中使用
bunkerdive

91

如果你不想 autofillHints

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

如果你想 autofillHints

minSdk> = 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不发出警告,在应用程序运行时不会产生任何影响


2
根据该文件- developer.android.com/reference/android/view/... -在android:autoFillHints一个电子邮件地址常数emailAddress,而不仅仅是email
ban-geoengineering

@ ban-geoengineering这个评论对我来说比整个答案更有用。多谢
Kartik

与已接受的答案相比,此答案的结构更好,可读性更好。
Touhid

0

您需要使用strings.xml文件并在其中启用字符串文本,例如:

<string name="editText2">Name</string>.

那么您需要activity_mail.xml-通过使用以下命令在其中启用autofillhint活动

android:hint="@string/editText2"

这个问题没有解决的办法
djardon
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.