监视EditText的更改

时间:2011-12-08 21:32:23

标签: java android

  

可能重复:
  Is there a way to fire an event when the contents of an EditText view have changed?

当用户更改编辑文本以格式化时,我想听。我可以使用某种监听器或接口吗?感谢

1 个答案:

答案 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) {}
});
相关问题