Reputation: 6286
Is there a way to switch off a SwitchPreference programmatically? I tried using setEnabled(false)
but that just disables the SwitchPreference, but the switch stays in the on position.
Is there a method to disable the switch programmatically so it goes back to the off position?
Upvotes: 0
Views: 2920
Reputation: 315
setEnabled as you say is to enable/disable the actual switch.
To turn it on/off programmatically try setChecked(true) / setChecked(false): http://developer.android.com/reference/android/preference/TwoStatePreference.html#setChecked(boolean)
Upvotes: 4