edittext限制小数点后两位
2018-08-13 本文已影响15人
alian_girl
edittext.addTextWatcher{
afterTextChanged(Editable p0){
//限制小数点后两位
var miniData =p0.toString()
var posDot = miniData.indexOf(".")
if (posDot >0 && (miniData.length - posDot -1 >2)) {
p0!!.delete(posDot +3, posDot +4)
}
}
}