【问题标题】:ListView text color change?ListView 文字颜色变化?
【发布时间】:2012-05-15 19:21:46
【问题描述】:

我知道你们中的许多人会说只是搜索 Google,但如果这很容易,我不会问 :)。 我有一个 ListView 并动态添加另一个列表等。

现在我想用 XML 更改文本颜色。

这是我的 XML:

<ListView
        android:id="@+id/listView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:smoothScrollbar="true"
        android:divider="@drawable/divider"
        android:dividerHeight="1dp"
        android:cacheColorHint="#000000"
        android:textColor="#D0640D" 
        android:fadeScrollbars="true">
</ListView>

有人可以帮忙吗? :)

【问题讨论】:

  • 您无法更改ListView 中的文本颜色。您的ListView 包含什么内容?
  • 看到这个 tuts ,,, 你可以改变行颜色samir-mangroliya.blogspot.in
  • 我的 ListView 包含一个 ArrayAdapter 和 contains String。
  • 我们可以在 ArrayAdapter 构造函数中指定 textViewResourceId 我们可以指定你的自定义 textView 布局

标签: android android-intent android-listview android-manifest


【解决方案1】:

您想更改列表项布局的textColor 属性,而不是列表本身。如果您使用的是预定义的项目布局之一,则只需将其复制到您的项目中并进行修改。

【讨论】:

  • 正如我所说,我的 xml 中没有列表项。我以编程方式添加它们
  • 当然可以,不能通过xml添加列表项,需要通过Adapter添加。现在适配器为每个项目使用某种布局。
【解决方案2】:

您要更改什么文本的颜色?如果是列表项,则需要为列表中的每个项设置正在使用的布局的文本颜色。

【讨论】:

  • 如何?我不使用 xml 而是通过编程方式添加它们
  • 然后在您以编程方式添加的视图上调用 setTextColor。
  • 在哪个对象中?在Listview,listAdapter还是ArrayList中?好像没有人有这个方法
  • ArrayAdapter listAdapter = new ArrayAdapter(InfoWifiActivity.this,android.R.layout.simple_list_item_1,networks); mylistview.setAdapter(listAdapter);
  • 我在互联网上找到了这个netmite.com/android/mydroid/frameworks/base/core/res/res/layout/… 我在布局文件夹中创建了一个新的 xml 文件,我添加了这行 android:textColor="#D0640D" android:cacheColorHint="#000000" no one of他们工作
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-03-13
  • 2022-01-09
  • 1970-01-01
  • 2015-06-04
  • 2016-05-27
  • 1970-01-01
  • 2011-08-16
相关资源
最近更新 更多