我想改变文本的颜色的的ListView
但我不能找到如何做到这一点..<
listViewObject =(ListView控件)findViewById(R.id.chathlist);
ArrayList的<字符串> chatHistory =新的ArrayList<字符串>();
chatHistory.add(消息1);
chatHistory.add(消息2);
chatHistory.add(消息3);
chatHistory.add(消息4);
chatHistory.add(消息5);
chatHistory.add(消息6);
chatHistory.add(消息7);
ArrayAdapter AA =新的ArrayAdapter<字符串>(getApplicationContext()
android.R.layout.simple_list_item_1,chatHistory);
listViewObject.setAdapter(AA);
listViewObject.invalidate();
我已经尝试了很多方法,但我不能改变颜色。这可能是简单的事情,但我打这一点。
我的XML文件是
< RelativeLayout的机器人:ID =@ + ID / chat_history_container
机器人:layout_width =FILL_PARENT机器人:layout_height =WRAP_CONTENT>
< ListView控件的android:paddingTop =15dip机器人:paddingBottom会=15dip
机器人:layout_width =FILL_PARENT机器人:以下属性来=15dip
机器人:layout_height =WRAP_CONTENT机器人:ID =@ + ID / chathlist
机器人:layout_gravity =center_horizontal
机器人:layout_centerInParent =真正的机器人:paddingRight =15dip
机器人:文字颜色=#FF0000机器人:listSelector =@可绘制/ gradient_box>
< / ListView控件>
< / RelativeLayout的>
解决方案
这些检查的详细信息:
http://www.anddev.org/view-layout-resource-problems-f27/changing-listview-text-color-t14527.html
Changing列表视图中的Android 文字颜色
更改的ListView文字颜色
请一个布局列表项,并绑定了一个ListAdapter。一个自定义列表视图的一个例子来看看这个网站:http://p-xr.com/android-tutorial-how-to-parseread-xml-data-into-android-listview/. (还有一个Eclipse项目的帖子底部)
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>
解决方案
Check these for more info:
http://www.anddev.org/view-layout-resource-problems-f27/changing-listview-text-color-t14527.html
Changing text color of list view in android
Change Text Color in ListView
Make a layout for your List items and bind that to a ListAdapter. See this site for an example of a custom listview: http://p-xr.com/android-tutorial-how-to-parseread-xml-data-into-android-listview/. ( There is an Eclipse project to the bottom of the post )
上一篇:在OutOfMemoryError错误AbstractStringBuilder enlargeBuffer错误、OutOfMemoryError、enlargeBuffer、AbstractStri
下一篇:ActivityNotFoundException当不同的包的targetClass在preferenceScreen不同、ActivityNotFoundException、preferenceSc