EditText Input type Issue

前端 未结 3 543
悲&欢浪女
悲&欢浪女 2020-12-22 07:32

There is a name EditText in my screen. I want to accept only alphabets means from a-z,A-Z and should not accept numbers, special chars.

I\'am using

相关标签:
3条回答
  • 2020-12-22 07:54

    Try using TYPE_TEXT_VARIATION_PHONETIC

    0 讨论(0)
  • 2020-12-22 08:05

    Your best bet is to use an InputFilter to restrict the characters that are permitted in your EditText control. You should be able to easily adapt the answer from How do I use InputFilter to limit characters in an EditText in Android? to do what you require.

    0 讨论(0)
  • 2020-12-22 08:10

    You will need to subclass EditText and detect key events. Reject any character other than a-zA-Z This is the only way to limit the acceptable characters.

    A person's name could contain a number so textPersonName is working correctly.

    0 讨论(0)
提交回复
热议问题