I have a ListView
and an EditText
. I implement addTextChangedListener
on EditText
to filter the ListView
content.
leftList.setTextFilterEnabled(true);
et_search.addTextChangedListener(filterTextWatcher);
and then the TextWatcher
is:
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) {
if (watcherAdapter==null) {
return;
}
watcherAdapter.getFilter().filter(s);
Log.e(TAG, "OnTextChange: " + s + " start: " + start +
" before: " + before + " count: " + count + " adapter: " +
watcherAdapter.getCount());
}
};
Condition:
- I have 10 items in
ListView
.
Question:
- When I first type the first character, why the
watcherAdapter.getCount()
returns10
(as initial) inListVie
w instead of the returned filter result count? ThewatcherAdapter.getCount(
) seems a-click late for the displayed result inListView
. - How I achieve to show
"No Result"
inListView
when there is no match results as I type on theEditText
?