Search code examples
androidandroid-listviewmultichoiceitems

Change text color of android.R.layout.simple_list_item_multiple_choice


I am trying to figure out how I can change the text color of android.R.layout.simple_list_item_multiple_choice

I know you can create your own listview with checkboxes but I really do not want to have to do that as the android.R.layout.simple_list_item_multiple_choice works perfectly, I would just like to know how to change the Text color.

I have come accross this question here but I do not understand how I can use the most voted up answer.

How can I override android.R.layout.simple_list_item_multiple_choice textview so I can change the color of it. Thank you.


Solution

  • Just make custom layout - simple_list_item_multiple_choice.xml like this -

    <CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android: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/listChoiceIndicatorMultiple"
        android:paddingLeft="6dip"
        android:paddingRight="6dip"
        android:textColor="#FF0000"
    />
    

    and use it in place of android.R.layout.simple_list_item_multiple_choice.xml