With 4.0.1 for example my mask puts it that way
Now if I put one with version 6.0.0
it appears to me in the following way
Now my concern is because the peso sign appears when my Android version is lower, my code of the mask is as follows
public TextWatcher amount(final EditText editText) {
return new TextWatcher() {
DecimalFormat dec = new DecimalFormat("0.00");
@Override
public void afterTextChanged(Editable arg0) {
}
@Override
public void beforeTextChanged(CharSequence s, int start,
int count, int after) {
}
private String current = "";
@Override
public void onTextChanged(CharSequence s, int start,
int before, int count) {
if(!s.toString().equals(current)){
editText.removeTextChangedListener(this);
String cleanString = s.toString().replaceAll("["+getResources().getString(R.string.MonedaMonto)+",.]", "").replace(" ","");
double parsed = Double.parseDouble(cleanString.replaceAll("\s","").trim());
// Obtienes la instancia del formateador
DecimalFormat decimalFormat = (DecimalFormat) NumberFormat.getCurrencyInstance();
// obtener la instancia del formatiador de simbolos
DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols();
// cambias el simbolo por US
symbols.setCurrencySymbol(getResources().getString(R.string.MonedaMonto)+" ");
// le asignamos el nuevo formateador de simbolo
decimalFormat.setDecimalFormatSymbols(symbols);
// formateamos
String formatted = decimalFormat.format((parsed/100));
current = formatted;
editText.setText(formatted);
editText.setSelection(formatted.length());
editText.addTextChangedListener(this);
}
}
};
}
Thanks a lot, because I really do not realize why this is