Android ListPreference项行文本颜色
我已经找了几天了,但是找不到一个我现在能找到工作的答案 我想允许用户在列表中为整个应用程序选择不同的主题,用于白天/晚上的目的。 问题是我找不到更改ListPreference行项目textColor文本颜色的方法。我找到的一些解决方案是关于使用属性的Android ListPreference项行文本颜色,android,textcolor,listpreference,Android,Textcolor,Listpreference,我已经找了几天了,但是找不到一个我现在能找到工作的答案 我想允许用户在列表中为整个应用程序选择不同的主题,用于白天/晚上的目的。 问题是我找不到更改ListPreference行项目textColor文本颜色的方法。我找到的一些解决方案是关于使用属性的 <item name="android:textColorPrimary">@color/red_color</item> @color/red\u color 在样式中,以设置该文本。但是,在我使用API 11进行测
<item name="android:textColorPrimary">@color/red_color</item>
@color/red\u color
在样式中,以设置该文本。但是,在我使用API 11进行测试期间,这没有任何效果。我在多次尝试后获得的结果几乎总是一样的:当为应用程序设置不同的样式时,我可以更改ListPreference的标题颜色,但不能更改行项目文本颜色:
以下是截图:
以下是我正在使用的样式:
<!-- Application theme. -->
<style name="AppTheme.Daylight" parent="AppBaseTheme">
<item name="android:background">@color/white</item>
<item name="android:panelBackground">@color/gray</item>
<item name="android:textColor">@color/black</item>
</style>
<style name="AppTheme.Dusk" parent="AppBaseTheme">
<item name="android:background">@color/black</item>
<item name="android:panelBackground">@color/gray</item>
<item name="android:textColor">@color/salmon</item>
</style>
<style name="AppTheme.Night" parent="AppBaseTheme">
<item name="android:background">@color/black</item>
<item name="android:panelBackground">@color/gray</item>
<item name="android:textColor">@color/red</item>
</style>
@颜色/白色
@颜色/灰色
@颜色/黑色
@颜色/黑色
@颜色/灰色
@颜色/鲑鱼
@颜色/黑色
@颜色/灰色
@颜色/红色
这是显示首选项片段xml文件
<PreferenceCategory
android:title="@string/preference_display_settings"
android:key="display_preferences">
<ListPreference
android:key="display_mode"
android:title="@string/preference_display_settings"
android:entries="@array/preference_display_mode_available"
android:entryValues="@array/preference_display_mode_values" />
</PreferenceCategory>
基本上我要问的问题是:
-如何在ListPreference中更改条目文本颜色
web上的一些文章正在解释如何创建自定义ListPreference视图,例如本文
- 创建curstom视图是更改文本颜色的唯一方法,还是ListPreference视图缺少属性
非常感谢,我是Android新手,刚从Coursera MOOC出来创建了这个开源应用程序。您可以在主题定义中更改属性的值
Android:textColorAlertDialogListItem
<item name="android:textColorAlertDialogListItem">@color/white</item>
@color/white
这对我很管用。祝你好运 谢谢,但是这个解决方案对我不起作用,但是我使用了@Reinier在没有“android:”前缀的情况下使用的技术,根据这个答案,如果我想为每一行设置不同的颜色,我应该怎么做?