2015-11-23 95 views

回答

0

這將只允許數字和字符:

android:digits="ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890" 
0

在EditText的XML中使用android:inputType="number"

0
//Allow only letters or digits 
    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.isLetterOrDigit(source.charAt(i))) { 
        return ""; 
       } 
      } 
      return null; 
     } 
    }; 

    EditText text = (EditText)findViewById(R.id.ifsc_et); 
    text.setFilters(new InputFilter[]{filter,new InputFilter.LengthFilter(11)});