【发布时间】:2011-07-30 16:53:52
【问题描述】:
我正在尝试更改 ListView 的文本 color,但我找不到如何做到这一点..
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>
【问题讨论】:
标签: android listview colors android-widget