If you want to change the color of all elements ListView, instead of passing the default android.R.layout.simple_list_item_single_choiceto ArrayAdapter, you must pass a custom XML list item that has a different TextColor attribute.
For example, created custom_list_item.xmlin the Layout folder:
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/text1"
android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"
android:checkMark="?android:attr/listChoiceIndicatorSingle"
android:paddingLeft="6dip"
android:paddingRight="6dip"
android:textColor="#FF0000"
/>
Then passed it to the adapter:
new ArrayAdapter<String>(this, R.layout.custom_list_item, stringList)
I have a list, all items are red.
source
share