我想在EditText 中只显示两位小数。我想在edit text中显示currency,但是想限制数在小数点后两位。
我不想用正则表达式这个方法。我查找的资料说java支持一些internal library函数能实现这个功能。请大家帮忙给点建议。
amount.setRawInputType(Configuration.KEYBOARD_12KEY);
amount.addTextChangedListener(new TextWatcher()
{
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
DecimalFormat formatVal = new DecimalFormat("##.##");
String formatted = formatVal.format(s);
amount.setText(formatted);
}