可能重复:
Is there a way to fire an event when the contents of an EditText view have changed?
当用户更改编辑文本以格式化时,我想听。我可以使用某种监听器或接口吗?感谢
答案 0 :(得分:10)
您要查找的内容可能是TextWatcher
,请查看此link以获取更多信息。以下是如何实现它:
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void afterTextChanged(Editable s) {}
});