If you want to have "," instead of the ".-" you need to set the input type of your editext to
mWeightEditText.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL | InputType.TYPE_CLASS_NUMBER);
EDIT
I forgot to add you the inputFilter
public static InputFilter[] setPriceFilters() {
return new InputFilter[]{new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
int digitsBeforeZero = 20;
int digitsAfterZero = 2;
String res = dest.toString().replace(" ", "");
if (res.isEmpty() && source.toString().equals(".")) {
return "";
} else if (res.contains(",") && source.toString().equals(".")) {
return "";
} else if (res.isEmpty() && source.toString().equals("0")){
return "";
}
Matcher matcher = Pattern.compile("[0-9]{0," + (digitsBeforeZero - 1) + "}+((\\,[0-9]{0," + (digitsAfterZero - 1) + "})?)?").matcher(res);
if (!matcher.matches())
return "";
return null;
}
}};
}
In my version I have a digit after and before zero check, you can remove it on the matcher if you don't need it