I would like to change the icon in my SwitchPreference (e.g. for enabling notification sound) once the state is changed from on to off and vice versa.
This is the code of my SwitchPreference:
<SwitchPreference
android:key="@string/pref_key_sound"
android:id="@+id/pref_key_sound"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:title="@string/pref_sound"
android:summaryOff="Off"
android:summaryOn ="On"
android:showText="true"
android:defaultValue="false"
android:icon="@mipmap/ic_volume"
/>
As you can see here I set just a fixed icon.