Search code examples
androidautocompletetextview

how to change suggetion textcolor in autocomplete textview


I use AutoCompleteTextView for suggesting data based on what I entered.

I want to change the character color of text entered and show suggestions in a drop-down list.

reference image

How can I change the suggested word's text color or change its background to match the edit text?

 <AutoCompleteTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/autocomplete_country"
    android:layout_width="fill_parent"
    android:textColorHint="@color/red"
    android:layout_height="wrap_content" />

and

 autocomplete_country = (AutoCompleteTextView) findViewById(R.id.autocomplete_country);
ArrayList<String> options = new ArrayList<String>();
    options.add("america");
    options.add("england");
    options.add("australia");

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_tv, options);
    autocomplete_country.setAdapter(adapter);

Solution

  • you can use android:popupBackground attributes in AutoCompleteTextView in layout XML.Customize it to your needs

    refer this link

    https://developer.android.com/reference/android/widget/AutoCompleteTextView.html#attr_android:popupBackground

    UPDATE:

    you can refer this link .uses a custom adapter

    Autocomplete textbox highlighting the typed character in the suggestion list