由网友(别害怕我在i)分享简介:您好我有一个EditText上,我想,让用户只输入非数字字符(比如AZ或az):有没有办法做到这一点?所有我所用的组合(文字,textPersonName的等等),让用户还可以选择号码。Helloi have an EditText on which i would like to let user enter...
您好 我有一个EditText上,我想,让用户只输入非数字字符(比如AZ或az):有没有办法做到这一点?所有我所用的组合(文字,textPersonName的等等),让用户还可以选择号码。
Hello i have an EditText on which i would like to let user enter only non-numeric chars (say A-Z or a-z): is there a way to do it? All the combinations i used (text,textPersonName an so on) let the user select also numbers.
在此先感谢 ℃。
推荐答案
我认为你必须写自己的输入过滤器,并将其添加到组过滤器的的EditText。这样的事情可能工作:
I think you have to write your own InputFilter and add it to the set of filters for the EditText. Something like this might work:
InputFilter filter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend)
{
for (int i = start; i < end; i++) {
if (!Character.isLetter(source.charAt(i))) {
return "";
}
}
return null;
}
};
edit.setFilters(new InputFilter[]{filter});
相关推荐
最新文章