I have an EditText where I listen for changes in text:
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
@Override
public void afterTextChanged(Editable s) {
// do stuff
}
});
This works fine so far, if I type something in the EditText, things in afterTextChanged() are executed. Now, in the same activity I have a ToggleButton which can change the string in the EditText. How do I prevent this text change due to the ToggleButton to trigger "afterTextChanged"?
PS: Not sure whether this is relevant, but specifically I have an EditText which accepts decimal or fractional numbers (e.g. "0.75" or "3/4") and the toggle button should toggle between fractional and decimal display, but should not trigger anything in "afterTextChanged" since the value stays the same (3/4=0.75).