MichelReap
MichelReap

Reputation: 5770

Android suggesting account names for Edit Text

I have an app to track parcels, so you can create a parcel by specifying name and track code. I guess that due to Android detecting the field is called "name", whenever the input gets focus I get a suggestion of names from the accounts google has stored on the phone.

How can I prevent this? These suggestions are useless in my case.

i tried specifying textNoSuggestions on my editText but it does not fix it.

Upvotes: 2

Views: 608

Answers (2)

Simon
Simon

Reputation: 2066

You can use the property android:importantForAutofill like this:

<RelativeLayout 
    android:importantForAutofill="noExcludeDescendants">

    
    <EditText
        android:id="@+id/txtNameFirst"
        android:hint="fist name"
        android:inputType="textPersonName|textCapWords"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"/>


    <EditText
        android:id="@+id/txtNameLast"
        android:hint ="last name"
        android:inputType="textPersonName|textCapWords"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtNameFirst"/>

</RelativeLayout>

Upvotes: 3

Csaba Farkas
Csaba Farkas

Reputation: 882

I think this has been answered before on SO. Please see this answer and try the workaround suggested.

It suggests that you should create your own custom EditText class by extending to AppCompatEditText and then you should override the getAutofillType method.

Upvotes: 0

Related Questions