I have been implementing a class which class extends ArrayAdapter and implements Filterable. The filtering part (in the performFiltering method()) seems to go ok, it fills the FilterResults object just as expected. But then I think I'm not doing it right on how to 开发者_StackOverflowpublish the results, atm I have :
protected void publishResults(CharSequence prefix, FilterResults results)
{
// NOTE: this function is *always* called from the UI thread.
subItems = (Vector)results.values;
notifyDataSetChanged();
}
But this simply won't "populate" my List with the received data. So now my question is how do I populate my List with the received results ? Do I have to do that programmatically ?
I had had the same problem. Try to be more aggresive:
protected void publishResults(CharSequence prefix, FilterResults results)
{
// NOTE: this function is *always* called from the UI thread.
subItems.clear();
subItems.addAll((Vector<T>)results.values);
notifyDataSetChanged();
}
Obviously I assume that your "results" object contains the right data
This approach has solved my problem
Actually I got it working with the next piece of code :
subItems = (Vector<serverContentElement>)results.values;
notifyDataSetChanged();
clear();
for(int i = 0; i < subItems.size(); i++)
add(subItems.get(i));
For me this has been the only way to get it working... Just a shame there aren't very concise examples on the net...
精彩评论