We can remove the TextWatcher for a field just before editing its text then add it back after editing the text.
Declare Text Watchers for both field1 and field2 as separate variables to give them a name: e.g. for field1
private TextWatcher Field_1_Watcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
};
then add the watcher using its name:
field1.addTextChangedListener(Field_1_Watcher)
for field1, and
field2.addTextChangedListener(Field_2_Watcher)
for field2
Before changing the field2 text remove the TextWatcher:
field2.removeTextChangedListener(Field_2_Watcher)
change the text:
field2.setText("")
then add the TextWatcher back:
field2.addTextChangedListener(Field_2_Watcher)
Do the same for the other field