列表视图中的Andr​​oid更改文本颜色

问题描述:

是有可能改变列表视图中的文本颜色的android?

is it possible to change list view's text color in android?

您可以使用主题设置样式为你的 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>

然后使用它:

Then to use it:

<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(&LT; p风格=颜色:红色&gt;中+ someText +&LT; / P&GT;&LT; p风格=颜色:蓝色 &gt;中+ someOtherText +&LT; / P&gt;中));