I have an EditText
to filter the items in the ListView
below it, which may contain more than 1000 items usually. The TextWatcher
is:
txt_itemSearch.addTextChangedListener(new TextWatcher() {
public void onTextChanged(CharSequence s, int start, int before, int count) {
fillItemList();
}
public void afterTextChanged(Editable s) {
}
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
});
The issue here is that with each letter typed by the user, the list is getting refreshed and it's this repeated list update which causes the UI to be slow.
How can I make the TextWatcher
wait for 1-2 secs and if no more input happens after 2 secs, then filter the list. Any suggestions guys?