There is a moment in my app, that I need to force to show all items in the suggestion list, no matter what the user has typed. How can I do that?
I tried to do somet
Basically, after 5-6 hours of experimentation to understand how the damn filter works, I wrote my own adapter which does exactly what I want:
public class burtuAdapteris extends ArrayAdapter implements Filterable {
ArrayList _items = new ArrayList();
ArrayList orig = new ArrayList();
public burtuAdapteris(Context context, int resource, ArrayList items) {
super(context, resource, items);
for (int i = 0; i < items.size(); i++) {
orig.add(items.get(i));
}
}
@Override
public int getCount() {
if (_items != null)
return _items.size();
else
return 0;
}
@Override
public String getItem(int arg0) {
return _items.get(arg0);
}
@Override
public Filter getFilter() {
Filter filter = new Filter() {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
if(constraint != null)
Log.d("Constraints", constraint.toString());
FilterResults oReturn = new FilterResults();
/* if (orig == null){
for (int i = 0; i < items.size(); i++) {
orig.add(items.get(i));
}
}*/
String temp;
int counters = 0;
if (constraint != null){
_items.clear();
if (orig != null && orig.size() > 0) {
for(int i=0; i 0) {
notifyDataSetChanged();
}
else {
notifyDataSetInvalidated();
}
}
};
return filter;
}
}
And it's simple to use, just replace original adapter with this:
final burtuAdapteris fAdapter = new burtuAdapteris(this, android.R.layout.simple_dropdown_item_1line, liste);
In my case liste is: ArrayList