AutoCompleteTextView background/foreground color

Viewed 19358

I am working on AutoCompleteTextView.Its working fine but the dropdown text is always white text on white background. this picture explain my problem

picture explain my problem

enter image description here

XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#000"
    >
    <!-- <AutoCompleteTextView  -->
    <AutoCompleteTextView
        android:id="@+id/text"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:hint="Tapez votre 1texte"
        android:textColor="#000"        
        />
</LinearLayout>

Java:

view = (AutoCompleteTextView)findViewById(R.id.text);        
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,data);
adapter.setDropDownViewResource(R.drawable.ic_action_search);//dd
view.setAdapter(adapter);
7 Answers

I solved this issue by doing a simple tricky Way,

Just change the Theme of your activity declared in your AndroidManifest.xml as,

 <activity
   android:name=".YourActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
            android:theme="@style/Theme.AppCompat.Light.NoActionBar"
            android:windowSoftInputMode="stateHidden"></activity>

and in the Activity as follows,

ArrayAdapter<String> adapter = new ArrayAdapter<String>
                (getActivity(), android.R.layout.select_dialog_item, arraylist);
Related