9

I have a AutoCompleteTextView within my activity that performs how it should. The dropdown bow is shown with correct entries etc. The problem is when the view looses focus the text is no longer visible. When focus is gained again the text is visible.

Has anyone else had this problem? Is it a bug or something I am doing wrong?

AverageMarcus
  • 903
  • 1
  • 9
  • 26
  • 3
    It turns out this is a bug in the android light theme. Workaround available here http://code.google.com/p/android/issues/detail?id=5237 – AverageMarcus Feb 06 '11 at 02:07
  • 2
    Wow. It's as simple as adding `android:textColor="@android:color/primary_text_light"` to the XML for your AutoCompleteTextView layout. – Nuthatch Aug 21 '11 at 18:16
  • @Nuthatch Thanks. I've just spent two days fighting with same problem. :) – Pawel Oct 19 '12 at 21:58

2 Answers2

0

It's as easy as set textcolor of textview,

 <AutoCompleteTextView
         android:layout_width="120dip"
         android:layout_height="wrap_content"
         android:singleLine="true"
         android:ems="10"
         android:textColor="@android:color/black" />
Hitesh Dhamshaniya
  • 2,886
  • 3
  • 24
  • 31
0

Maybe when you don't focus the Item,TextColor is same as background color on current Theme .so you can't see them,just see the item text that you focus.

Solve : set different color against background_color. you can use android.R.layout.simple_dropdown_item_1line and so on when you create Adapter ,or your own textViewResourceId like:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
   android:textSize="20dp"
   android:gravity="center_vertical" 
   android:id="@android:id/text1" 
   android:paddingLeft="6.0dip" 
   android:paddingRight="6.0dip" 
   android:layout_width="fill_parent" 
   android:layout_height="50.0dip"
   android:textColor="@android:color/black"
   android:textColorHighlight="@android:color/black"    />
  • this assumes `black` is appropriate for the current device theme. `primary_text_light` is safer if you mean "dark text on a light background" – Nuthatch Feb 28 '13 at 18:27