private EditText mEtCode;
mEtCode = (EditText) findViewById(R.id.et_code);
mEtCode.setKeyListener(new DigitsKeyListener() {
@Override
protected char[] getAcceptedChars() {
return getResources().getString(R.string.can_only_input_number_alphabet).toCharArray();
}
@Override
public int getInputType() {
return InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;//明文显示,InputType.TYPE_TEXT_VARIATION_PASSWORD密文显示
}
});
string.xml
<string name="can_only_input_number_alphabet">qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890</string>