<分区>
Possible Duplicate:
Is there a way to fire an event when the contents of an EditText view have changed?
我想听听用户何时更改编辑文本以对其进行格式化。我可以使用某种类型的监听器或接口(interface)吗?谢谢
<分区>
Possible Duplicate:
Is there a way to fire an event when the contents of an EditText view have changed?
我想听听用户何时更改编辑文本以对其进行格式化。我可以使用某种类型的监听器或接口(interface)吗?谢谢
最佳答案
您正在寻找的可能是一个 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) {}
});
关于java - 监听一个EditText的变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8437975/