4

in my AutoCompleteTextView the text is not visible after I have choosen an item from the suggestions list. I have tried with setTextColor(android.R.color.black) but it doesen't work. I use Theme.Light in Manifest. Has anybody an idea what i can do?

Thanks, in advance

Tiziano

Taziano
  • 83
  • 2
  • 8
  • 1
    change your text color and see `setTextColor(android.R.color.white)` – Samir Mangroliya Jun 04 '12 at 10:24
  • 1
    the background is white, so nothing could happen – Taziano Jun 04 '12 at 10:28
  • Resources res = getResources(); int color = res.getColor(android.R.color.black); – Dheeresh Singh Jun 04 '12 at 10:29
  • Thanks for your answers, but it I found out that it was not a problem of the wrong text color. The problem was the alignment of the view, I set it to AlignParentRight true, after deleting this rule, the text was visible. Sorry for wasting your time! – Taziano Jun 04 '12 at 10:47
  • After I made some changes on the layout with actv, the text was not visible again, I dont know why! The solution from Dheeresh Singh works! – Taziano Jun 05 '12 at 12:18

6 Answers6

5

please 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

Dheeresh Singh
  • 15,643
  • 3
  • 38
  • 36
4

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

Sonoo Jaiswal
  • 255
  • 1
  • 4
  • 12
1

Create custom layout my_dropdown_item.xml:

<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);
rudakovsky
  • 182
  • 1
  • 5
1

It will be 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);
0

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

gustavomcastro
  • 155
  • 1
  • 9
0

One more simple way, just set background color of your AutoCompleteTextView to white. Like this: android:background="@android:color/white"

Jacky
  • 133
  • 1
  • 13