Reputation: 3031
I have 10 edittexts in my layout. There is any way to check if any edittext values was changed? I know that I can use afterTextChange etc, but I want to know there is any one method to check all edittexts?
Upvotes: 1
Views: 3014
Reputation: 12153
Make each EditText
have the same TextChangedListener
TextWatcher tw = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
}
};
editText1.addTextChangedListener(tw);
editText2.addTextChangedListener(tw);
...
Upvotes: 8