如何在 Android 中使用 TextWatcher 类? [英] How to use the TextWatcher class in Android?
本文介绍了如何在 Android 中使用 TextWatcher 类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我如何屏蔽 EditText
中的 substring 或如何更改 EditText
子字符串输入到密码类型 或 替换 另一个字符 像这样 123xxxxxxxxx3455
Can anyone tell me how to mask the substring in EditText
or how to change EditText
substring input to password type or replace by another character like this 123xxxxxxxxx3455
String contents = et1.getText().toString();
et1.setText(contents.replace.substring(0, contents.length()-2),"*");
请告诉我如何在 Android 中使用 TextWatcher
方法.
Please, tell me how I can use the TextWatcher
method in Android.
推荐答案
用于TextWatcher
...
et1.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
这篇关于如何在 Android 中使用 TextWatcher 类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文