I created a subclass of PreferenceFragment that implements CompoundButton.OnCheckedChangeListener . I have one preference that contains Switch (a subclass of CompoundButton ). Here's the callback I created when the switch value changes:
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mAppController.doSomething(isChecked); Log.v("rose_tag", "hi"); }
I declare preference in OnCreate as follows:
Switch mySwitch = (Switch) myView.findViewById(R.id.switch); mySwitch.setEnabled(true); mySwitch.setOnCheckedChangeListener(this);
The callback is called when the first view is opened (the breakpoint in the callback hits), but does not print the logs, and the callback is never called again, even when I turn the switch on and off. How can I make this feedback?
I also tried creating a built-in anonymous listener. I also tried using a simple Button with an onClick , and that didn't work either.
source share