EditView
来源:互联网 发布:社交网络电影图解 编辑:程序博客网 时间:2024/05/20 18:51
1、密码
密码小眼睛(显示密码和隐藏密码)可以在密码EditView控件外层加TextInputLayout ,不需要自己手动去写。
在app下的 build.gradle 中引入
compile 'com.android.support:appcompat-v7:25.0.0'
compile 'com.android.support:design:25.0.0'
在布局文件中使用
<android.support.design.widget.TextInputLayout
android:id="@+id/id_pwd_Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
>
<EditText
android:id="@+id/id_et_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/edt_pwd_hint"
android:maxLines="1"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
android:id="@+id/id_pwd_Layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:passwordToggleEnabled="true"
>
<EditText
android:id="@+id/id_et_pwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/edt_pwd_hint"
android:maxLines="1"
android:inputType="textPassword" />
</android.support.design.widget.TextInputLayout>
ps: 当输入类型设置为android:inputType="textPassword"时(或textWebPassword或numberPassword),app:passwordToggleEnabled="true"才有效,才会出现小眼睛。就算不设置app:passwordToggleEnabled="true"只要输入类型设置为textWebPassword或numberPassword或textPassword一样会有小眼睛。输入类型是textVisiblePassword时,不会出现小眼睛,这个值本身就明确表示显示密码。
感谢以下两篇博文的博主:
点击打开链接http://www.jb51.net/article/102273.htm
点击打开链接https://segmentfault.com/a/1190000009282096
点击打开链接http://www.jianshu.com/p/de9c19d73450
2、android:inputType常用取值
android:inputType="number"//数字格式
android:inputType="numberSigned"//有符号数字格式
android:inputType="numberDecimal"//可以带小数点的浮点格式
android:inputType="phone"//拨号键盘
android:inputType="datetime"//日期+时间格式
android:inputType="date"//日期键盘
android:inputType="numberSigned"//有符号数字格式
android:inputType="numberDecimal"//可以带小数点的浮点格式
android:inputType="phone"//拨号键盘
android:inputType="datetime"//日期+时间格式
android:inputType="date"//日期键盘
android:inputType="time"//时间键盘
<EditText android:id="@+id/id_et" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:maxLines="1" android:imeOptions="actionNext" android:imeActionLabel="下一个" android:layout_weight="1" android:inputType="numberDecimal" android:maxLength="5" android:textSize="16dp" android:hint="5位(算上小数点5位)" />
这里只收录了数值类型,文本类型等类型请查看链接
点击打开链接 http://blog.csdn.net/xqf222/article/details/9789143
3、限制条件setFilters//实现功能:输入框mEdit中限输入5位(算上小数点5位),小数点后只允许有1位小数private int mDecimalNumber = 1;//小数点后的位数 1表示小数点后一位(如0.1)EditText mEdit=(EditText)findViewById(R.id.id_et); mEdit.setFilters(new InputFilter[]{new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { String lastInputContent = dest.toString(); int sourceLenth = lastInputContent.length(); if (sourceLenth >= 5) {//限定只能输入5位(包括小数点 如123.5) return ""; } if (lastInputContent.contains(".")) {//限制小数点后数据位数 int index = lastInputContent.indexOf("."); if (dend - index >= mDecimalNumber + 1) { return ""; } } return null; } }});
方法filter返回空字符串,表示匹配不成功,返回null表示匹配成功source新输入的字符串start新输入的字符串起始下标,一般为0end新输入的字符串终点下标,一般为source长度-1dest输入之前文本框内容dstart原内容起始坐标,一般为0dend原内容终点坐标,一般为dest长度-1
点击打开链接http://blog.csdn.net/vqqyuan/article/details/44676379
点击打开链接http://blog.csdn.net/yichenandanxia/article/details/50914089
感谢以上博文的博主,谢谢各位!如有不妥的地方,请各位博主评论区留言,本人看到会立刻处理。
阅读全文
0 0
- EditView
- editView
- EditView
- xml ----editview
- EditView 属性
- EditView控件
- EditView控件
- android_7 editView
- Android EditView属性解析
- Android EditView属性解析
- EditView编辑框
- 哭死了 editView 聚焦
- Android EditView 属性大全
- 图片插入EditView中
- EditView中插入图片
- EditView实现左右选择
- Android入门/EditView(五)
- Android EditView属性
- Android学习之将一个Activity设置main Activity
- OpenCV学习(12) 图像的腐蚀与膨胀(3)
- caffe源码追踪-- Google Protocol Buffer
- Android bindservice失败解决方法
- H5开发技术将不断突破
- EditView
- Python编码详解
- 回调函数理解
- UART与USART
- KMP算法 一般详解,NEXT数组 一般理解 k = next[k] ——综合转载
- D
- 查看linux系统版本命令
- 遍历数组和对象的方法
- 《梦醒》