4

在我从建议列表中选择一个项目后,在我的 AutoCompleteTextView 中文本不可见。我试过 setTextColor(android.R.color.black) 但它不起作用。我在清单中使用 Theme.Light。有人知道我能做什么吗?

提前致谢

蒂齐亚诺

4

6 回答 6

5

请试试

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

于 2012-06-04T10:32:39.090 回答
4

使用 android.R.layout.select_dialog_item 而不是 android.R.layout.simple_dropdown_item_1line,它会正常工作。

于 2013-01-18T12:16:45.773 回答
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);
于 2014-07-26T12:44:18.117 回答
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);
于 2014-11-04T15:02:38.440 回答
0

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

通过扩展主题并覆盖键入文本和建议文本的 2 种样式的解决方法:

在清单中使用扩展主题: ... ...

创建使用固定样式的新主题 (res/values/themes.xml): ... @style/AutoCompleteTextViewLight @style/Widget.DropDownItemLight ...

创建固定颜色的样式(res/values/styles.xml): ... @android:color/primary_text_light @android:color/primary_text_light

于 2014-02-03T13:33:18.787 回答
0

一种更简单的方法,只需将 AutoCompleteTextView 的背景颜色设置为白色。像这样:android:background="@android:color/white"

于 2017-01-18T07:39:28.030 回答