Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
674 views
in Technique[技术] by (71.8m points)

android - Change ListView's textcolor

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.

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...