android edittext 限制输入框小数位数

来源:互联网 发布:标准差计算软件 编辑:程序博客网 时间:2024/06/05 03:17

在输入小数点的时候,监听小数点后面的位数,只要大于两位就立马删掉。

@Overridepublic void afterTextChanged(Editable arg0) {int posDot = arg0.toString().indexOf(".");if (arg0.length() - posDot - 1 > 2) {arg0 = arg0.delete(posDot + 3, posDot + 4);holder.pmpmListNewpriceEdittext.setText(arg0);}list.get(position).SLPRC = arg0.toString();}









0 0