I have a ListView that I filter with and EditText that I have a TextWatcher on to get the text change events. Everything works great until you delete the text out of edit text. The filter then just remains as the first letter and doesn’t go back to no filter.
What am I doing wrong? Here is the code for the TextWatcher, I even tried to disable the filter but that had no effect.
EditText txtFilter = (EditText) this.findViewById(R.id.txtFilter);
txtFilter.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
if(s.length()==0)
{
lv.setTextFilterEnabled(false);
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after)
{
}
public void onTextChanged(CharSequence s, int start, int before, int count)
{
lv.setTextFilterEnabled(true);
lv.setFilterText(s.toString());
}
});
Thanks for your help
i think that Adil Soomro answer is bad … i just look at android source and setFilterText and it looks like
so as you can see it’s setting adapter with filter …
you should use
lv.clearTextFilter();instead oflv.setTextFilterEnabled(false);