Good day.

There was a need to correct the checkboxes in the application, namely: change the image. A little googling, came across a solution. So, in the application theme we register

<item name="android:checkboxStyle"> @style /CheckBoxStyle</item> 

further create a style

 <style name="CheckBoxStyle" parent=" @android :style/Widget.CompoundButton.CheckBox"> <item name="android:button">@drawable/checkbox_pink</item> </style> 

and to complete the selector:

 <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/checkbox_off_grey" android:state_checked="false" android:state_enabled="false"/> <item android:drawable="@drawable/checkbox_on_grey" android:state_checked="true" android:state_enabled="false"/> <item android:drawable="@drawable/checkbox_off_pink" android:state_checked="false" android:state_enabled="true"/> <item android:drawable="@drawable/checkbox_on_pink" android:state_checked="true" android:state_enabled="true"/> <item android:drawable="@drawable/checkbox_off_pink"/> </selector> 

I decided to check this whole thing out. I run the application, and all the checkboxes are in the "off state", and the state switching itself does not work. For confidence in the correct operation of the selector, I took the standard selector \sdk\platforms\android-21\data\res\drawable\btn_check.xml and replaced \sdk\platforms\android-21\data\res\drawable\btn_check.xml with the one that was kindly provided by Google. Replacing all the resources, re-launched the application. The result is the same. Not plowing and all. Are there any reasons for the incorrect operation of selectors?

    1 answer 1

    A week later I found a similar question, the solution was to rename files with selectors.
    ps in eclipse Alt + Shift + R on the selected file. I hope that someone else will help.