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
A tricky solution for this is:
Add this line
setTheme(android.R.style.Theme); before setContentView()
in your activity file in which your autocompletetextview is present. Let me know if this works.
I tried setting up the theme before setcontext, tried different resources parameter in arrayAdapter and tried different theme ,but nothing helped.
Then I changed the context from 'this' to 'getApplicationContext' but the problem was persistent.
Finally I changed the context parameter to "getBaseContext()" and the problem was solved.
i got my solution in slecting layout of "select_dialog_singlechoice
ArrayAdapter<String > s1= new ArrayAdapter<String>
(this,android.R.layout.select_dialog_singlechoice,state);
enter image description here
instead of get application context write "this" in ArrayAdapter<>;
try using different layouts u will definately solve your queries
Answer by didldum https://code.google.com/p/android/issues/detail?id=5237
workaround by extending the theme and overriding the 2 styles for the typed text and the suggest text:
use an extended theme in your manifest: ... ...
create the new theme (res/values/themes.xml) which uses fixed styles: ... @style/AutoCompleteTextViewLight @style/Widget.DropDownItemLight ...
create the styles (res/values/styles.xml) which fix the color: ... @android:color/primary_text_light @android:color/primary_text_light
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);
This question might be old but I believe this is very important for me to share. I had been experiencing the same problem as OP but it is because I was using 'getApplicationContext()' in place of 'this'
Wrong
ArrayAdapter<String> adapter = new ArrayAdapter<String>
(getApplicationContext(), android.R.layout.simple_list_item_1, PLACES);
Correct
ArrayAdapter<String> adapter = new ArrayAdapter<String>
(this, android.R.layout.simple_list_item_1, PLACES);