Android EditText輸入限制最大字元長度 和 限制只能輸入數字和字母(包含大小寫)
阿新 • • 發佈:2019-01-23
如題:Android EditText輸入限制最大字元長度 和 限制只能輸入數字和字母(包含大小寫),主要是如下兩個屬性:
android:maxLength="10"
android:digits="0123456789qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM"
<EditText android:id="@+id/aeid" android:layout_width="match_parent" android:layout_height="30dp" android:layout_marginTop="10dp" android:background="@drawable/gray_shape" android:gravity="center" android:hint="@string/login_aeid" android:singleLine="true" android:maxLength="10" android:digits="0123456789qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM" android:textColor="@color/gray" android:textColorHint="@color/hint_color" mykeyboard:xml="@xml/qwertyupper" />
參考這個部落格:http://blog.csdn.net/zhuzhiqiang_zhu/article/details/51220471,不過沒有控制大寫的情況,我上面補充了一下