InputType代码中设置为小数无效:
?
? ? 1,第一中解决办法 ? ? ?
??InputType.TYPE_NUMBER_FLAG_SIGNED代表符号位
mEditText.setInputType(InputType.TYPE_CLASS_NUMBER|InputType.TYPE_NUMBER_FLAG_DECIMAL|InputType.TYPE_NUMBER_FLAG_SIGNED);
?
??
? ? 2,第二种
?
public static DigitsKeyListener getInstance(boolean sign, boolean decimal) Returns a DigitsKeyListener that accepts the digits 0 through 9, plus the minus sign (only at the beginning) and/or decimal point (only one per field) if specified. 返回DigitsKeyListener即0到9接受数字,再加上如果指定减号(只在开始时)和/或小数点(每场仅一个)。
?
mEditText.setKeyListener(DigitsKeyListener.getInstance(false,true));
?
??
? ?3,第三种
?
官方文档定义:
public static DigitsKeyListener getInstance(String accepted) Returns a DigitsKeyListener that accepts only the characters that appear in the specified String. Note that not all characters may be available on every keyboard. 返回accepted指定的数字
?
??
mEditText.setKeyListener(DigitsKeyListener.getInstance("123456789."));
?
?
百度现在找点东西真的好难啊,希望早点放开Google。
?
代码设置inputType为numberDecimal无效的解决办法
原文:http://baihe747.iteye.com/blog/2284823