I have some CheckBoxPreferences and I have no problem changing the icon for them through xml as shown below and here but since the user has other ways of triggering the checkbox's actions than directly clicking on it (i.e. perhaps in another activity or even another application) I want to be able to programmatically set the icon depending on value changes that occur along with the action. For example, if Bluetooth is on, I want the icon to be one image and when bluetooth is off, I want it to be a different image. Is it possible to programmatically change this image?
<CheckBox xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+android:id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/check_box_icon"
android:clickable="true"
android:focusable="false"
android:/>