i use a TextWatcher to change pressed key value. my goal is that replace some characters while typing. for example when i type keys, if reached "S" character, replaces it with "a" character. my question is: should i do it in beforeTextChanged?? how? can anyone give me an example?
I know that this post is a couple of years old, but both versions did not work for me and have build a hybrid between the two answers.
@Override
public void afterTextChanged(Editable editable) {
if (editable.toString().contains(",")) {
Editable ab = new SpannableStringBuilder(editable.toString().replace(",", ""));
editable.replace(0, editable.length(), ab);
}
}