本文介绍了更改复选框值,而不触发onCheckChanged的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有 setOnCheckedChangeListener 为我的复选框执行 有一种方式我可以调用checkbox.setChecked(false); without triggering the onCheckedChanged推荐答案不,你不能做。直接从 setChecked 调用 onCheckedChanged 方法。你可以做的是以下:No, you can't do it. The onCheckedChanged method is called directly from setChecked. What you can do is the following:mCheck.setOnCheckedChangeListener (null);mCheck.setChecked (false);mCheck.setOnCheckedChangeListener (mListener);查看 CheckBox的源代码,并执行 setChecked :public void setChecked(boolean checked) { if (mChecked != checked) { mChecked = checked; refreshDrawableState(); // Avoid infinite recursions if setChecked() is called from a listener if (mBroadcasting) { return; } mBroadcasting = true; if (mOnCheckedChangeListener != null) { mOnCheckedChangeListener.onCheckedChanged(this, mChecked); } if (mOnCheckedChangeWidgetListener != null) { mOnCheckedChangeWidgetListener.onCheckedChanged(this, mChecked); } mBroadcasting = false; }} 这篇关于更改复选框值,而不触发onCheckChanged的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-14 21:43