此类java类实现了
TextWatcher“监视”您的编辑文本,监视对文本所做的任何更改:
public abstract class TextValidator implements TextWatcher { private final TextView textView; public TextValidator(TextView textView) { this.textView = textView; } public abstract void validate(TextView textView, String text); @Override final public void afterTextChanged(Editable s) { String text = textView.getText().toString(); validate(textView, text); } @Override final public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override final public void onTextChanged(CharSequence s, int start, int before, int count) { }}
在您的中
EditText,您可以将该文本查看器设置为其监听器
editText.addTextChangedListener(new TextValidator(editText) { @Override public void validate(TextView textView, String text) { }});
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)