How to restrict special characters from an Android EditText field?

Viewed 24593

How to restrict special characters from an Android EditText field?

5 Answers

Just put below xml line inside edittext block.

android:digits="abc"

This will allow to enter only a,b and c characters.

I created a class for more flexible settings of input constraints to EditText:

https://github.com/devapro/NumberWatcher

It is implementation only for numbers input, but you can change it for any of the types.

Related