AutocompleteTextView text is not displayed

in my autocomplete TextView, the text does not appear after I selected an item from the list of sentences. I tried with setTextColor (android.R.color.black) but it does not work. I am using Theme.Light in the manifest. Does anyone know what I can do?

Thanks in advance

Tiziano

+4
source share
6 answers

try

Resources res = getResources(); int color = res.getColor(android.R.color.black); setTextColor(color ) 

http://sree.cc/google/android/defining-custom-colors-using-xml-in-android

+5
source

Use android.R.layout.select_dialog_item than the android.R.layout.simple_dropdown_item_1line file, it will work fine.

+3
source

Create your own my_dropdown_item.xml layout:

 <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="?android:attr/spinnerDropDownItemStyle" android:singleLine="true" android:layout_width="match_parent" android:layout_height="wrap_content" android:minHeight="40dip" android:ellipsize="marquee" android:textColor="#000000"/> 

Then use it:

 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.my_dropdown_item, YOURARRAY); 
+1
source

This will work fine:

 adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_dropdown_item_1line, string_resource); Resources res = getResources(); int color = res.getColor(android.R.color.black); autoCompleteTextView.setTextColor(color); autoCompleteTextView.setAdapter(adapter); 
+1
source

The answer to this question didldum https://code.google.com/p/android/issues/detail?id=5237

expanding the theme and redefining 2 styles for the entered text and sentence text:

use the extended theme in your manifest: ......

create a new theme (res / values โ€‹โ€‹/themes.xml) that uses fixed styles: ... @ style / AutoCompleteTextViewLight @ style / Widget.DropDownItemLight ...

create styles (res / values โ€‹โ€‹/styles.xml) that fix the color: ... @android: color / primary_text_light @android: color / primary_text_light

0
source

Another easy way: just set the background color of your autocomplete to white. For example: android:background="@android:color/white"

0
source

Source: https://habr.com/ru/post/1415936/


All Articles