如上标题问题
tvDesValue.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
InputFilter lengthfilter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
// 删除等特殊字符,直接返回
if (".".equals(source.toString()) || "0".equals(source.toString())) {
if (dest.toString().length() == 0)
return "";
}
String dValue = dest.toString();
String[] splitArray = dValue.split("\\.");
if (splitArray.length > 1) {
String dotValue = splitArray[1];
int diff = dotValue.length() + 1 - 4;
if (diff > 0) {
return "";
}
}
return null;
}
};
tvDesValue.setFilters(new InputFilter[] { lengthfilter });