gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 03:43:21 24 4
gpt4 key购买 nike

正在创建 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com