I'm working on an autocompletetextview that will work off of a key value system, and am trying to find out what I need to do to make publishResults work, as the results param being passed to publishResults here is correct in the debugger, however I have no idea what it should correspond to or how to cause it to display the results, can anyone help? the creation of this object is in another file, and looks like this:
autoCompleteBox.setAdapter(new AutoCmpAdapter(this, android.R.layout.simple_dropdown_item_1line));
and the rest of the code is as follows:
public class AutoCmpAdapter extends ArrayAdapter<String> implements Filterable {
protected Filter filter;
protected ArrayList<String> items;
protected ArrayList<String> res;
String lWds[] = { "HOMER", "TOM" };
String sWds[] = { "SIMPSON", "JONES" };
public AutoCmpAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
filter = new PhysFilter();
res = new ArrayList<String>();
}
public Filter getFilter() {
return filter;
}
private class PhysFilter extends Filter {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
FilterResults f = new FilterResults();
res.clear();
if (constraint != null) {
ArrayList<String> res = new ArrayList<String>();
for (int x = 0; x < sWds.length; x++) {
if (sWds[x].toUpperCase().startsWith(constraint.toString().toUpperCase())) {
res.add(lWds[x]);
}
}
f.values = res.toArray();
f.count = res.size();
}
return f;
}
@Override
protected void publishResults(CharSequence constraint, FilterResults results) {
if (results.count > 0) {
Log.println(Log.INFO, "Results", "FOUND");
notifyDataSetChanged();
} else {
Log.println(Log.INFO, "Results", "-");
notifyDataSetInvalidated();
}
}
}
}