我需要知道 EditText 是否被更改,而不是用户是否在字段中输入了一些文本,而只需要知道 String 是否被更改。
最佳答案
你需要一个
TextWatcher
在这里查看它的实际效果:
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) {
}
}
关于android - 如何检查 EditText 是否已更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7391891/