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)
}
}
}
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)
}
}
}
本文标题:edittext限制小数点后两位
本文链接:https://www.haomeiwen.com/subject/boyubftx.html
网友评论