問題描述
我的屏幕上有一個(gè)名稱EditText
.我只想接受 a-z,A-Z 中的字母表示并且不應(yīng)接受數(shù)字、特殊字符.
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.
我正在使用 inputtype="textPersonName"
但它不起作用,它接受意味著顯示所有數(shù)字、字符等.
I'am using inputtype="textPersonName"
for that but its notworking, it accepts means showing all numbers, chars etc..
對(duì)于電話字段 inputtype="phone"
正在工作,它接受意味著僅在字段中顯示數(shù)字.
For phone field inputtype="phone"
is working it accepting means showing numbers in field` only.
為什么會(huì)這樣?
推薦答案
最好的辦法是使用 InputFilter 來限制 EditText 控件中允許的字符.您應(yīng)該能夠輕松地適應(yīng) 如何在 Android 中使用 InputFilter 來限制 EditText 中的字符? 做你需要的.
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.
這篇關(guān)于EditText 輸入類型問題的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!