在我的AutoCompleteTextView文本不可见后,我从建议列表中选择一个项目。我已经尝试setTextColor(android.R.color.black),但它没有工作。我在Manifest中使用Theme.Light。有没有人知道我能做些什么?AutocompleteTextView文本不可见
感谢,提前
提香
在我的AutoCompleteTextView文本不可见后,我从建议列表中选择一个项目。我已经尝试setTextColor(android.R.color.black),但它没有工作。我在Manifest中使用Theme.Light。有没有人知道我能做些什么?AutocompleteTextView文本不可见
感谢,提前
提香
请尽量
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
使用android.R.layout.select_dialog_item比android.R.layout.simple_dropdown_item_1line,它会工作正常。
通过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
创建自定义布局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);
这将是工作罚款:
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);
一个更简单的方法,只需将您的AutoCompleteTextView的背景颜色设置为白色。就像这样:android:background="@android:color/white"
更改文字的颜色,看看'setTextColor(android.R.color.white)' –
背景是白色的,所以没有什么可能发生 – Taziano
资源RES = getResources(); int color = res.getColor(android.R.color.black); –