android - 文本颜色与微调器不匹配

标签 android drop-down-menu android-spinner

正在创建 android 应用程序,其中包含一些微调器。这里出现了一些问题。有时,微调器项目的文本颜色会因设备而异。我怎么能克服这个....

这里是为微调器设置值的代码。

ArrayAdapter<PatientCaseList> adapter = new ArrayAdapter<PatientCaseList>(getApplicationContext(), android.R.layout.simple_spinner_item,caseList);
adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line);
spinnerCaseNames.setAdapter(adapter);

当我在 android 2.3.3 中使用此应用程序时它可以正确显示选项,但在 3.0 中它不显示

最佳答案

每个设备都会在 Spinner 上强制执行自己的主题。

您不应使用内置的微调器布局。而是创建您自己的布局。

my_spinner_layout.xml

 <TextView  
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:textColor="#FF0000"         
        />

然后使用

 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.my_spinner_layout,list);

关于android - 文本颜色与微调器不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15408307/

相关文章:

javascript - jquery 显示/隐藏 div 下拉菜单不起作用

java - 在微调器中隐藏字符串数组值

android - 从 Android RSS 阅读器中的描述节点问题中获取数据

android - 当 dex.force.jumbo=true 时,Dexopt 在非常大的 APK(无序 method_idx)上失败

android - downloadOnly 是同步的还是异步的?

android - 在 Android 中为微调器设置多个值

安卓 : Fill Spinner From Java Code Programmatically

android - 使用 ColorMatrix 时如何理解和选择值?

css - 如果导航栏中的绝对位置为 :hover ul,则下拉菜单不会在 IE9 上显示

jquery - 如何使用 Jquery 更改 DropDownList 的选定文本?