The inputType
numberDecimal
in EditText
uses the dot '.' as decimal separator. In Europe it's common to use a comma ',' instead. Even though my locale is set as german the decimal separator is still the '.'
Is there a way to get the comma as decimal separator?
For Mono(Droid) solutions:
I think this solution is less complex than the others written here:
This way when you press the '.' in the soft keyboard nothing happens; only numbers and comma are allowed.
you could use the following for different locales
to get localize your input use:
and then add:
than don't forget to replace "," with "." so Float or Double can parse it without errors.
IMHO the best approach for this problem is to just use the InputFilter. A nice gist is here DecimalDigitsInputFilter. Then you can just:
I decided to change comma to dot only while editing. Here is my tricky and relative simple workaround:
someDecimalFormatter will use comma or dot depends on Locale