ListView filter for android

I have an adapter and I use ad.getFilter().filter(s); for the listView filter.
This works well if I write a single word in EditText.
It does not work (the result does not build) if you write a space Character after the word.
For example, I would like to make a filter with the name and surmane. I want to insert "Mario Rossi" into the edittext and get the result .. I hope I explained. Many thanks.

 private TextWatcher filterTextWatcher = 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) { ad.getFilter().filter(s); } }; 
+6
source share
1 answer

Your code is perfect, but some little mistake is there

 private TextWatcher filterTextWatcher = new TextWatcher() { public void afterTextChanged(Editable s) { ad.getFilter().filter(s); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }; 
0
source

Source: https://habr.com/ru/post/901662/


All Articles