Is there any way to remove a Listener from a View
in android? I have a Checkbox
that I attached a CheckChangedListener
to. The problem is that calling setChecked()
on it causes my listener to fire.
If I can't just remove a listener, is there a way to prevent the listener from firing when I call setChecked()
manually versus it being checked from a touch event?
Well, I found the answer. This doesnt appear to be documented anywhere, but I went through the code for the View
class and if you pass null to the setClickListener methods, it will remove the listener.
checkbox.setOnCheckChangedListener(null);
This should work for any event listener.