代码设置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。
阅读更多
相关文章推荐
- H5新特性 input type=date 在手机上默认提示显示无效解决办法
- 设置android:inputType="textPassword"失效的解决办法
- 关于input输入框type为number型时 maxlength无效解决办法
- Glide设置圆角图片后设置ImageVIew的scanType="centerCrop"无效解决办法
- 设置文件下载页面的代码时下载后的数据出现数据错误的错误原因和解决办法
- stm32f4xx_it.c: Error: C3065E: type of input file 'DRIVER' unknown 解决办法
- 关于Qt使用QPalette设置Qwidget背景色无效的解决办法及分析
- 关于AutoCompleteTextView设置背景无效的解决办法
- javascript 中设置window.location.href跳转无效问题解决办法
- Java动态设置ImageView的setPadding无效,解决办法
- Android设置requestWindowFeature(Window.FEATURE_NO_TITLE)无效的解决办法
- 使用input type=file标签进行文件上传时,在安卓手机中的微信浏览器中不能调起相机,但是在苹果手机中的微信浏览器中可以调用相机。解决办法很简单, <input type="file" nam
- FF中span设置大小无效,只根据内容变化大小解决办法
- 上传文件form表单enctype="multipart/form-data"传值解决办法(代原代码)
- android在代码中利用Spinner控件设置联动地区的解决办法
- 给View设置selector无效的解决办法。
- vs2005断点设置无效的解决办法
- Unity3D学习(七):Unity多重采样抗锯齿设置无效的解决办法
- 表格设置padding值无效的原因和解决办法
- 表格单元格td设置宽度无效的解决办法