I have setOnCheckedChangeListener
implemented for my checkbox
Is there a way I can call
checkbox.setChecked(false);
For anyone that stumbles across this, one simpler way to do this is to just use a tag on the checkbox and then check that tag on its listener (code is in Kotlin):
checkBox.tag = false
checkBox.setOnCheckedChangeListener{ buttonView, isChecked ->
if(checkBox.tag != true) {
//Do some stuff
} else {
checkBox.tag = false
}
Then when accessing just set the tag to true before you set the isChecked to true when you want to ignore the value change:
checkBox.tag = true
checkBox.isChecked = true
You could also map the tag to a key by using the alternative setTag method that requires a key if you were worried about understandability. But if its all contained to a single class a few comment strings will be more than enough to explain whats happening.