I have an EditText field and a CheckBox. The behavior I am looking for is 'one or the other should be valid'. (1) So if there's text in the EditText and if the user clicks the CheckBox, the EditText field should automatically be set to "". My code is if CheckBox.isChecked() EditText.setText(""), and this works as expected.
(2) Likewise, if the CheckBox is checked and if the user starts entering text in the EditText, the CheckBox needs to be unchecked. My code is on EditText..afterTextChanged listener, if CheckBox.isChecked() CheckBox.toggle(). This sort of seems to happen, but the EditText field doesn't let go of focus. So the next time, I try to click the CheckBox (#1), the EditText receives focus first even though I clicked the CheckBox, and then it clears the CheckBox, so I am never able to check the CheckBox, because the EditText keeps receiving focus and keeps unchecking the CheckBox.
Is there anyway I could make this happen? Please let me know. Thanks.