Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch Set Checked False

I've a Switch with a listener:

mSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
}

Doing:

mSwitch.setChecked(false);

has no effect, callback is not triggered. Instead like this:

mSwitch.setChecked(true);
mSwitch.setChecked(false);

works as expected. Am I doing something wrong? If the checkbox state is false and one use setChecked(false), the normal behaviour is to skip callback? Or is it a bug?

like image 784
Jumpa Avatar asked Oct 19 '25 03:10

Jumpa


1 Answers

It will be Called when the checked state of a compound button has changed.

So if its state is already false it won't be called when you call false.

like image 125
Nongthonbam Tonthoi Avatar answered Oct 22 '25 03:10

Nongthonbam Tonthoi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!