preference.isEnabled = false
(setEnabled) cannot be used as it disabled the click event as well.
Instead, listen to the click and switch back to original value everytime the value is changed.
val pref = findPreference("pref_key")pref.setOnPreferenceClickListener { Toast.makeText(activity, "Click Detected", Toast.LENGTH_LONG).show() (it as SwitchPreference).isChecked = false true}