1

I want to custom the check mark in my several checkedtextview. I wanted to use a "simple" solution, so i did that :

    if(serviceChecked.isChecked()){
    serviceChecked.setChecked(false);
    serviceChecked.setCheckMarkDrawable(null);
} else {
    serviceChecked.setChecked(true);
    serviceChecked.setCheckMarkDrawable(R.drawable.ic_action_done);
}

I've two problems with this solution :

The first is, it's running only the first time, when I check one of my checktextview, uncheck, and check again, my drawable is not visible.

The second problem is, we can see again the "default" checkmarck (the blue)....

How can I resolve it ?

Thx,

deveLost
  • 1,151
  • 2
  • 20
  • 47

1 Answers1

4

Extending the CheckTextBox, you shouldn't need to change the setCheckMarkDrawable. Just set it once, and the setChecked should appropriately set the checked/non-checked state. Your drawable should be defined in XML, something like this:

<selector xmlns:android="http://schemas.android.com/apk/res/android">  

    <item android:state_checked="true"
        android:drawable="@drawable/checkbox_checked" /> <!-- checked -->

    <item android:state_pressed="true"
        android:drawable="@drawable/checkbox_checked" /> <!-- pressed -->

    <item android:drawable="@drawable/checkbox_default" /> <!-- default -->

</selector>
Community
  • 1
  • 1
PearsonArtPhoto
  • 38,970
  • 17
  • 111
  • 142