AutoCompleteTextview Color set white by default

强颜欢笑 提交于 2019-11-29 09:06:56
R.daneel.olivaw

This a logged bug,

You can find some ways to fix it in the same link.

Auto complete text view bug

Bug solution

Note: This solution will not work with lollipop

I hope it helps...

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.

For Lollipop, all the work around solutions in the reported bug will not work.

I finally reached a solution that works with lollipop and the previous OS versions by using android.R.layout.simple_spinner_dropdown_item with the adapter instead as the following:

ArrayAdapter<String> adapter = new ArrayAdapter<>(getContext(), android.R.layout.simple_spinner_dropdown_item, suggestionList);

This will solve the White text issue without any need to change Theme attributes or anything.

Laura Fernández Carballo

You can use simple_list_item_1 in ArrayAdapter,

ArrayAdapter<String> autoadapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,cities);
            city = (AutoCompleteTextView) findViewById(R.id.location);

Another solution is to quit the style in AndroidManifest.xml

NOTE: This solution does not work with lollipop OS versions

Well, we can't set the "suggestion text" color, but we can change its background! Just use android:popupBackground="YOUR_COLOR_HEX" as in this example:

<AutoCompleteTextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/autocompletetextview"
        android:layout_gravity="center_horizontal"
        android:hint=" ... "
        android:popupBackground="#000000"/>

Works also on Lollipop! ;)

You should use

setTheme(android.R.style.Theme); before setContentView

It worked for me :)

Set background color of pop up ascity.setDropDownBackgroundResource(R.color.indicator);

if anyone still have the same issue

This worked for me

autocompleteF.setBackgroundColor(color.black);
anapsil

Add this to your theme:

<item name="android:autoCompleteTextViewStyle">@style/Widget.AppCompat.AutoCompleteTextView</item>

This worked for me First use this before setContentView()

setTheme(android.R.style.TextAppearance_DeviceDefault_Medium_Inverse);

you have to change some colors in colors.xml in the values folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!