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!
Okay, It turns out the answer was quite simple, sometimes the best way it to just check the source code :)
AutoSearchTextView has a method
public void onFilterComplete(int count)which in turn callsprivate void updateDropDownForFilter(int count), if the count is zero the dropdown will be hidden.You must set count on your FilterResults object returned from your Filter
protected FilterResults performFiltering(CharSequence constraint)method.solved the issue.