The toggle button does not go OFF in the UI view, and I set onCheckedChangeListener . It stays on and turns gray. This happens on Simulator with API15, but does not appear in API19 on my real device. Is this a code or a simulator?
The last sr.setChecked(false) allows only the gray button, but does not disable it.
Minimal example for reproducing behavior: class var:
Switch sr; Switch srs;
onCreate includes:
sr = (Switch) findViewById(R.id.switch_ros); srs = (Switch) findViewById(R.id.switch_ros_stream); sr.setOnCheckedChangeListener(this); srs.setOnCheckedChangeListener(this);
onCheckedChanged includes:
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { buttonView.setChecked(false); }
EDIT : Instead of Nexus_4_API_15, I tried Nexus_5_API_19 and it works fine. This seems to be an Android bug. 
source share