列表视图中的Andr​​oid更改文本颜色 [英] Changing text color of list view in android

查看:104
本文介绍了列表视图中的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;中));

这篇关于列表视图中的Andr​​oid更改文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆