在EditText 过滤Filtering 数据

emailText.setKeyListener(new NumberKeyListener() {
 @Override
 public int getInputType() {
  return InputType.TYPE_MASK_VARIATION;
 }

 @Override
 protected char[] getAcceptedChars() {
  return new char[]{'i', 'o', 'p', 'a', 's', 'd', 'f', 'g',
                        'h', 'j', 'k', 'l', 'z', 'x', 'q', 'w', 'e', 'r', 't',
   'y', 'u', 'c', 'v', 'b', 'n', 'm', '.', '@', '_', '1', '2',
   '3', '4', '5', '6', '7', '8', '9', '0',};
 }
});

 

 

-------------------------------------------------------------------------------

emailText.setKeyListener(new NumberKeyListener() {
 @Override
 public int getInputType() {
  return InputType.TYPE_NULL;
 }

 @Override
 protected char[] getAcceptedChars() {
  return new char[]{'i', 'o', 'p', 'a', 's', 'd', 'f', 'g',
                        'h', 'j', 'k', 'l', 'z', 'x', 'q', 'w', 'e', 'r', 't',
   'y', 'u', 'c', 'v', 'b', 'n', 'm', '.', '@', '_', '1', '2',
   '3', '4', '5', '6', '7', '8', '9', '0',};
 }
});

.....................................................................................

 

emailText.setText("EditText element");
emailText.setKeyListener(new NumberKeyListener() {
 @Override
 public CharSequence filter(CharSequence source, int start, int end,
  Spanned dest, int dstart, int dend) {
  return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
 }

 @Override
 public int getInputType() {
  return InputType.TYPE_MASK_VARIATION;
 }
 @Override
 protected char[] getAcceptedChars() {
  return new char[]{'i', 'o', 'p', 'a', 's', 'd', 'f', 'g',
                'h', 'j', 'k', 'l', 'z', 'x', 'q', 'w', 'e', 'r', 't',
  'y', 'u', 'c', 'v', 'b', 'n', 'm', '.', '@', '_', '1', '2',
  '3', '4', '5', '6', '7', '8', '9', '0',};
 }
});

 

你可能感兴趣的:(C++,c,C#,F#,J#)