在android中更改列表视图的文本颜色 [英] Changing text color of list view in android
本文介绍了在android中更改列表视图的文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更改 Android 中列表视图的文本颜色.任何人都可以告诉我它是如何完成的吗?
I am trying to change the text color of a listview in Android. Can anyone please give me a heads up on how it's done?
推荐答案
您可以使用主题来设置 TextViews
的样式.来自 Android 开发网站.
You can use themes to set the styles for your TextViews
.
From the Android dev site.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="CodeFont" parent="@android:style/TextAppearance.Medium">
<item name="android:textColor">#00FF00</item>
<item name="android:typeface">monospace</item>
</style>
</resources>
然后使用它:
<TextView style="@style/CodeFont" />
编辑 - 基于评论
您在同一个 TextView 中询问了多种颜色:你最好的选择是使用 html.例如,您在 TextView 中设置的内容:
You asked about multiple color in the same TextView: Your best bet is to use html. Which you set in a TextView for example:
myTextView.setText(Html.fromHtml("<p style="color:red">" + someText + "</p><p style="color:blue">"+ someOtherText + "</p>"));
这篇关于在android中更改列表视图的文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文