0
我試圖設置ListView中顯示的不同文本顏色(TextView)。這是ListView控件:如何在ArrayAdapter中設置TextView的顏色?
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#a0a0a0"/>
這是row.xml TextView的:
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rowtext"
android:layout_width="fill_parent"
android:layout_height="40sp"
android:textSize="15sp"
android:textColor="#a0a0a0"
android:background="#000000"
android:lines="1"
android:singleLine="true"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true" />
這是列表的填充方式:
ArrayAdapter<String> fileList = new ArrayAdapter<String>(this, R.layout.row, lstItem);
setListAdapter(fileList);
這一切工作正常。但是現在,我想給列表中的每個文件指定它自己的顏色。那可能嗎?
你需要一個定製的適配器。 – Blackbelt
@Blackbelt說什麼。有很多教程(谷歌:「Android自定義列表視圖」),並在這裏回答了許多問題。 – 323go