I tried the following link But state_focused didn't work.
checkbox_selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/checked" android:state_checked="true"/>
<item android:drawable="@drawable/unchecked" android:state_checked="false"/>
<item android:state_checked="true" android:state_focused="false" android:drawable="@drawable/unchecked_focus"/>
<item android:state_checked="false" android:state_focused="true" android:drawable="@drawable/unchecked_focus" />
</selector>
In my class, I add like this.
cbx.setButtonDrawable(R.drawable.checkbox_selector);
First is unchecked state, second is focused state and last is for checked state. I have also tried android:state_pressed
but it didn't work. Is there another way to do it?
Thanks.