Answer the question
In order to leave comments, you need to log in
How to work with search in android?
There is a code
public void onTextWatcher(final CustomAdapter customAdapter){
this.customAdapter = customAdapter;
textWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3){
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
customAdapter.getFilter().filter(editTextSearch.getText().toString());
if (CustomAdapter.subItems.size() == 0){
Toast.makeText(context,"нет совпадений",Toast.LENGTH_SHORT).show();
}
}
@Override
public void afterTextChanged(Editable editable) {
}
};
editTextSearch.addTextChangedListener(textWatcher);
}
Answer the question
In order to leave comments, you need to log in
customAdapter.getFilter().filter()
this is done in a separate thread and the result will come later. Therefore
uses the previous result.
If you have a custom filter, then the condition must be checked in publishResults
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question