title: How do I use publishResults() method when extending Filters in Android?
body: <p>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:</p>
  
  <pre><code>autoCompleteBox.setAdapter(new AutoCmpAdapter(this, android.R.layout.simple_dropdown_item_1line));
  </code></pre>
  
  <p>and the rest of the code is as follows:</p>
  
  <pre><code>public class AutoCmpAdapter extends ArrayAdapter&lt;String&gt; implements Filterable {
  
      protected Filter filter;
      protected ArrayList&lt;String&gt; items;
      protected ArrayList&lt;String&gt; res;
      String lWds[] = { "HOMER", "TOM" };
      String sWds[] = { "SIMPSON", "JONES" };
  
      public AutoCmpAdapter(Context context, int textViewResourceId) {
          super(context, textViewResourceId);
          filter = new PhysFilter();
          res = new ArrayList&lt;String&gt;();
      }
  
      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&lt;String&gt; res = new ArrayList&lt;String&gt;();
                  for (int x = 0; x &lt; 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 &gt; 0) {
                  Log.println(Log.INFO, "Results", "FOUND");
                  notifyDataSetChanged();
              } else {
                  Log.println(Log.INFO, "Results", "-");
                  notifyDataSetInvalidated();
              }
          }
      }
  }
  </code></pre>