I have an AutoSearchTextView in the actionbar. When I filter the data the dropdown hides and then shows very quickly. I really would prefer the effect on the play store, where you filter results, the dropdown is always visible but the content in the dropdown changes.
This is my filter code in my Adapter, run history query, gets the history and sets the list items.
@Override
public Filter getFilter() {
if (filter == null) {
filter = new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
ResortFilterResult result = new ResortFilterResult();
String substr = constraint.toString().toLowerCase();
if (constraint != null) {
if (constraint.length() > 0) {
result.setHistory(runHistoryQuery(substr));
}
if (constraint.length() >= 3) {
LCResort[] resorts = searchResortWithQuery(substr);
result.setQueryResults(Arrays.asList(resorts));
}
}
FilterResults filterResults = new FilterResults();
filterResults.values = result;
return filterResults;
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
ResortFilterResult result = (ResortFilterResult)results.values;
history = result.getHistory();
resorts = result.getQueryResults();
notifyDataSetChanged();
}
};
}
return filter;
}
EDIT: I am one step closer - It turns out dismiss dropdown on the TextView is being called every time I type a new character!