如何从一个Android的EditText字段限制的特殊字符? [英] How to restrict special characters from an Android EditText field?
问题描述
如何从一个Android的EditText字段限制的特殊字符?
How to restrict special characters from an Android EditText field?
推荐答案
您是否尝试添加安卓位数=ABCDE ..... 0123456789
属性?
虽然安卓位数
指定它是一个数字字段,它的工作对我来说,将其设置为接受信件,以及和特殊字符,以及(在SDK-测试7)。
Have you tried adding the android:digits="abcde.....0123456789"
attribute?
Although the android:digits
specify that it is a numeric field, it does work for me to set it to accept letters as well, and special characters as well (tested on SDK-7).
如果这不工作,那么你就必须实施的KeyListener
请参见:<一href="http://developer.android.com/reference/android/widget/TextView.html#setKeyListener(android.text.method.KeyListener)" rel="nofollow">http://developer.android.com/reference/android/widget/TextView.html#setKeyListener(android.text.method.KeyListener)
If this doesn't work then you'll have to implement KeyListener
see: http://developer.android.com/reference/android/widget/TextView.html#setKeyListener(android.text.method.KeyListener)
这篇关于如何从一个Android的EditText字段限制的特殊字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!