我试图改变文本颜色ListView
的但我不能找到该怎么做.. <更改ListView的文本颜色
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();
我已经尝试了许多方法,但我不能改变颜色。这可能是一件简单的事情,但我正在为此而战。
我的XML文件是
<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>
如果你的listview设置为singleChoice来显示RadioButton,这当然是没用的。编写自己的自定义布局然后需要开发自己的适配器和更多的代码。如果所有列表都没有显示任何内容,但是没有单选按钮的文本项目,则表示解决方案没有问题。 – AndroidDev 2013-01-07 09:19:37