Wednesday, 26 August 2015

android editText allow only alpha-numeric characters in Android



First there is no solution to show a alpha-numeric keyboard, there is no such keyboard.

for keyboard information:

http://developer.android.com/intl/zh-cn/reference/android/text/InputType.html
https://developer.android.com/intl/zh-cn/training/keyboard-input/style.html

But you can limited user's input for alpha-numeric only ("*-"will still clickable on the keyboard, but the input box doesn't accept it.)

In the XML, put this:
android:digits="abcdefghijklmnopqrstuvwxyz1234567890 "


For a simple input box (just one line, e.g. username), you must have this in your xml:
android:inputType="text"
otherwise it will not show "done" key in your keyboard.






No comments:

Post a comment