Android开发之EditText输入框限制输入数字和字母的实现方式
生活随笔
收集整理的這篇文章主要介紹了
Android开发之EditText输入框限制输入数字和字母的实现方式
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
老套路先看效果圖:
?
非常簡單只需要在xml不居中添加一個屬性就可以了:
android:digits="0123456789qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM"完整如下:
<EditTextandroid:id="@+id/etLoginPwd"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="18dp"android:layout_marginTop="20dp"android:layout_marginRight="15dp"android:layout_toRightOf="@+id/tvLoginPwd"android:background="@null"android:digits="0123456789qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM"android:hint="請輸入密碼"android:maxLength="20"android:textColor="#999999"android:textSize="12sp" />當(dāng)然也可以直接使用android:inputType="textPassword"這個屬性也可以達(dá)到相同的效果
總結(jié)
以上是生活随笔為你收集整理的Android开发之EditText输入框限制输入数字和字母的实现方式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 京东 “百亿补贴”入口现已上线
- 下一篇: android sina oauth2.