2

您可以禁用键盘上的某些键以防止用户输入错误的字符吗?

4

1 回答 1

0

以下代码是禁用数字和字符

{
  final InputFilter filter = new InputFilter() { 


        @Override
        public CharSequence filter(CharSequence source,
                int start, int end, Spanned dest, int dstart,
                int dend)
        {
              for (int i = start; i < end; i++)
              { 
                   if (Character.isDigit(source.charAt(i))||Character.isLetter(source.charAt(i)))
                   { 
                           return ""; 
                   } 
           } 
            return null;
        } 
}; 

answerTXT.setFilters(new InputFilter[]{filter});

}
于 2013-07-08T13:52:14.403 回答