"Missing autofillHints attribute"
AndroidAndroid Problem Overview
I have an issue with Palette -> Text
When I want to set some view, I receive a message problem "Missing autofillHints attribute"
Any suggestions?
Android Solutions
Solution 1 - Android
Perhaps you are using an EditText
. autofillHints
is used in API 26 and above for filling empty EditText
s and it's actually suggesting which type of content should be placed in there.
Just add :
android:autofillHints="username" // the type of content you want
To your EditText
and warning will disappear.
> You do this using the new android:autofillHints
attribute to tell
> autofill
what type of content you expect, and
> android:importantForAutofill
to tell autofill
which views you want (or
> do not want) to be filled.
>
Read: https://medium.com/@bherbst/getting-androids-autofill-to-work-for-you-21435debea1
And this: https://developer.android.com/guide/topics/text/autofill-services
Edit:
You can however set:
android:importantForAutofill="no"
To the component to tell it is not important to fill and get rid of the error.
Solution 2 - Android
autofillHints
If you don't want minSdk>=26 .
Should use android:importantForAutofill=no
if you don't want autofill hint
<EditText
android:importantForAutofill="no"/>
minSdk<26
Add android:importantForAutofill
then tools:targetApi
to make IDE don't this warning about API level
<EditText
android:importantForAutofill="no"
tools:targetApi="o"
/>
autofillHints
If you want Autofill service enable by default even if we don't set autofillHints
attribute. specify an autofillHints will help autofill service work better like our expection. see documents here
minSdk>=26
-
Just need to add
android:autofillHints="{a contant value}"
(eg:"android:autofillHints="password"
) (use constant from here)
minSdk<26, add tools:targetApi
to make IDE don't this warning
<EditText
android:autofillHints="emailAddress"
tools:targetApi="o"/>
Note
-
autofillHints
andimportantForAutofill
only used in API 26 and higher but we still can use it in API < 26 without crash (you can see in this answer) (it don't crash but ofcourse it don't have any effect with API < 26) -
tool:...
just use to make IDE don't warning, it will not effect anything when application running sotools:ignore="Autofill
don't help you hide autofill hint
Solution 3 - Android
you need to the strings.xml file and enable the string text in there, for example:
<string name="editText2">Name</string>.
then you need to activity_mail.xml
- and then enable the autofillhint activity there, by using:
android:hint="@string/editText2"