我需要知道,如果一个的EditText
改变与否,不在于是否用户输入的领域的一些文字,但只有当字符串
被改变。
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
在这里看到它在行动:
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) {
}
}