2012-06-04 51 views
4

在我的AutoCompleteTextView文本不可見後,我從建議列表中選擇一個項目。我已經嘗試setTextColor(android.R.color.black),但它沒有工作。我在Manifest中使用Theme.Light。有沒有人知道我能做些什麼?AutocompleteTextView文本不可見

感謝,提前

提香

+1

更改文字的顏色,看看'setTextColor(android.R.color.white)' –

+1

背景是白色的,所以沒有什麼可能發生 – Taziano

+0

資源RES = getResources(); int color = res.getColor(android.R.color.black); –

回答

3

使用android.R.layout.select_dialog_item比android.R.layout.simple_dropdown_item_1line,它會工作正常。

0

通過didldum回答https://code.google.com/p/android/issues/detail?id=5237

通過擴展主題和重寫2種樣式鍵入的文本和建議文本解決方法:

使用您的清單擴展的主題:......

創建新的主題(RES /價值/的themes.xml),它採用固定樣式:... @風格/ AutoCompleteTextViewLight @風格/ Widget.DropDownItemLight ...

創建樣式(RES /價值/風格.xml)修復co LOR:... @android:彩色/ primary_text_light @android:彩色/ primary_text_light

1

創建自定義佈局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"/> 

然後使用它:

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

這將是工作罰款:

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

一個更簡單的方法,只需將您的AutoCompleteTextView的背景顏色設置爲白色。就像這樣:android:background="@android:color/white"