您的位置:首页 > 编程语言

代码设置inputType为numberDecimal无效的解决办法

2016-03-20 00:57 281 查看

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。

 

阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐