Change Checkbox value without triggering onCheckChanged

前端 未结 19 1023
广开言路
广开言路 2020-11-30 00:18

I have setOnCheckedChangeListener implemented for my checkbox

Is there a way I can call

checkbox.setChecked(false);
         


        
19条回答
  •  旧巷少年郎
    2020-11-30 00:57

    Add this code inside OnCheckedChangeListener:

    if(!compoundButton.isPressed()) {
                return;
    }
    

    This will help us to figure out weather checkBox state was changed programmatically or by user action.

提交回复
热议问题