Mask for EditText in Android

user725803 picture user725803 · May 2, 2011 · Viewed 12.1k times · Source

I want to limit input in the EditText of all symbols except figures, "?" And "*". How I am able to do it?

Answer

EboMike picture EboMike · May 2, 2011

You could add a TextWatch via addTextChangedListener. afterTextChanged allows you to modify the text after it was modified.

(Keep in mind that there are many ways to modify a text field - entering text, auto-complete through IME, copy and paste). Handle those properly in the TextWatch.