Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what's the best way to apply a mask to an EditText on Android?

Tags:

java

android


what's the best way to mask a EditText on Android?
I Would like my EditText to behave like this decimal number input here. Is there a easy way to do this?

like image 821
marcosbeirigo Avatar asked Oct 08 '10 12:10

marcosbeirigo


1 Answers

You have to programmatically set an InputFilter on your EditText by setFilters.

From the documentation:

InputFilters can be attached to Editables to constrain the changes that can be made to them.

You can even change the users input, for example by adding a decimal point which is what you want if I get you correctly.

like image 138
thumbmunkeys Avatar answered Oct 12 '22 02:10

thumbmunkeys