How to block special characters in androids editTe

2019-07-14 03:37发布

问题:

How to block special characters in androids editText? by not using android:digits!!

is there any other way around, even programmatically?

回答1:

EditText has an onTextChanged listener, you can follow the characters the user is inputting and if the character is illegal you just delete it. Not the most elegant way, but hope it makes it. Good luck!