更改 ListView 的文本颜色 [英] Change ListView's textcolor

查看:28
本文介绍了更改 ListView 的文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改 ListView 的文本 颜色,但我找不到如何做到这一点..<

I am trying to change the text color of the ListView but I cant find how to do that..<

    listViewObject= (ListView) findViewById(R.id.chathlist);        
    ArrayList<String> chatHistory = new ArrayList<String>();
    chatHistory.add("Msg 1");
    chatHistory.add("Msg 2");
    chatHistory.add("Msg 3");
    chatHistory.add("Msg 4");
    chatHistory.add("Msg 5");
    chatHistory.add("Msg 6");
    chatHistory.add("Msg 7");
    ArrayAdapter aa=new ArrayAdapter<String>(getApplicationContext(),
    android.R.layout.simple_list_item_1, chatHistory);
    listViewObject.setAdapter(aa);
    listViewObject.invalidate();

我尝试了很多方法,但我无法改变颜色.这可能是一件简单的事情,但我正在为此而战.

I have tried many ways but I can't change the color. It maybe a simple thing but I'm fighting with this.

我的 XML 文件是

My XML file is

  <RelativeLayout android:id="@+id/chat_history_container"
            android:layout_width="fill_parent" android:layout_height="wrap_content">
            <ListView android:paddingTop="15dip" android:paddingBottom="15dip"
                android:layout_width="fill_parent" android:paddingLeft="15dip"
                android:layout_height="wrap_content" android:id="@+id/chathlist"
                android:layout_gravity="center_horizontal"
                android:layout_centerInParent="true" android:paddingRight="15dip"
                 android:textColor="#FF0000"  android:listSelector="@drawable/gradient_box" >
            </ListView>
  </RelativeLayout>

推荐答案

查看这些以获取更多信息:

Check these for more info:

http:///www.anddev.org/view-layout-resource-problems-f27/changed-listview-text-color-t14527.html

更改android中列表视图的文本颜色

更改 ListView 中的文本颜色

为您的 List 项目制作布局并将其绑定到 ListAdapter.

Make a layout for your List items and bind that to a ListAdapter.

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

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