【问题标题】:how to set text color in list view in android app如何在android应用程序的列表视图中设置文本颜色
【发布时间】:2011-08-09 12:17:12
【问题描述】:

在我的应用程序中,我创建了一个列表视图并在列表中添加了一些文本。在我的编码部分中,文本被添加为数组适配器以具有复选框。在布局中,我为列表视图赋予了白色,因此文本看起来很沉闷。如何将文本颜色设置为黑色。

【问题讨论】:

  • 我已经给出了带有复选框的阵列适配器....

标签: android listview text colors


【解决方案1】:

在您的 xml 中设置文本颜色

< TextView
android:id="@+id/list_content"
android:textColor="#000000"
android:gravity="center"
android:text="sample"
android:layout_margin="4dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>

【讨论】:

  • 我已经给出了带有复选框的数组适配器,所以我没有在布局中创建文本视图......
  • 为什么android无法识别textColor资源?
【解决方案2】:

如果文本是作为 TextView 的一部分添加的,您应该可以对其调用 setTextColor(int)。

【讨论】:

    猜你喜欢
    • 2011-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-29
    • 2011-01-22
    • 1970-01-01
    • 1970-01-01
    • 2019-07-08
    相关资源
    最近更新 更多