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?
            Asked
            
        
        
            Active
            
        
            Viewed 2,850 times
        
    1 Answers
8
            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);
...
        Andrew Brooke
        
- 12,073
 - 8
 - 39
 - 55
 
- 
                    The only problem I have with this is how to tell *which* `EditText` has been edited? – Squonk Sep 15 '15 at 19:04
 - 
                    This is not important for me. I need only info if any Edittext has been edited – edi233 Sep 15 '15 at 19:13
 - 
                    1You could do something like this for that case @Squonk http://stackoverflow.com/a/6172024/2278598 – Andrew Brooke Sep 15 '15 at 19:14
 - 
                    I need override onSelectionChanged(). Is there any similar way to that? I saw the source of TextWatcher.java. It only includes those 3 functions. – Fisher Jan 12 '20 at 13:04