我需要知道 EditText 是否被更改,而不是用户是否在字段中输入了一些文本,而只需要知道 String 是否被更改.
I need to know if an EditText was changed or not, not whether or not the user inputted some text in the field, but only the if String was changed.
你需要一个TextWatcher
在这里查看它的实际效果:
See it here in action:
EditText text = (EditText) findViewById(R.id.YOUR_ID);
text.addTextChangedListener(textWatcher);
private TextWatcher textWatcher = new TextWatcher() {
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
}
}
这篇关于如何检查 EditText 是否已更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!