I am trying to show my database data into list view. And I want a text box in which user will enter age and according to that age list view will be updated. But I want to filter those result without button event. Is this possible? If so, then how?
            Asked
            
        
        
            Active
            
        
            Viewed 504 times
        
    -2
            
            
        - 
                    https://stackoverflow.com/questions/1645209/how-can-i-filter-listview-data-when-typing-on-edittext-in-android https://stackoverflow.com/questions/14625423/detect-when-user-enters-data-into-edittext-immediately-shows-answer https://stackoverflow.com/questions/7391891/how-to-check-if-an-edittext-was-changed-or-not https://stackoverflow.com/questions/35595313/how-to-get-a-result-data-to-edit-text-without-clicking-on-button https://stackoverflow.com/questions/1737009/how-to-dynamically-update-a-listview-on-android – Mike M. Jan 18 '18 at 05:32
2 Answers
0
            
            
        You use a TextWatcher :
myEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
Put you code inside afterTextChanged
 
    
    
        ColonD
        
- 954
- 10
- 28
0
            
            
        Yes you can. 
attach your EditText with an addTextChangedListener()
        your_editText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (!TextUtils.isEmpty(s) ){
                //TODO filter data here
            }
        }
        @Override
        public void afterTextChanged(Editable editable) {
        }
    });
 
    
    
        Md Tanbir Hossen
        
- 393
- 4
- 13
