Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hakan's answer is good, but it's related to Cursor use. In general you can write your own adpater, for instance by extending the ArrayAdapter. In my application, the Adapter had to do a lot of "strange things" like search in db, then re-filter the Cursors, add other results, changing other... I did something like this:</p> <pre><code>public class MyAdapter extends ArrayAdapter { private List&lt;String&gt; mObjects; //the "strange Strings" private MyHelper dbHelper; // an helper to make query private MyFilter mFilter; // my personal filter: this is very important!! private final Object mLock=new Object(); //functions very similar to the ArrayAdapter implementation @Override public int getCount() { return mObjects.size(); } @Override public Filter getFilter() { if (mFilter==null) { mFilter=new TeamFilter(); } return mFilter; } @Override public String getItem(int position) { return mObjects.get(position); } @Override public int getPosition(String item) { return mObjects.indexOf(item); } //the trick is here! private class MyFilter extends Filter { //"constraint" is the string written by the user! @Override protected FilterResults performFiltering(CharSequence constraint) { FilterResults results=new FilterResults(); //no constraint =&gt; nothing to return if ((constraint==null)||(constraint.length()==0)) { synchronized (mLock) { ArrayList&lt;String&gt; list=new ArrayList&lt;String&gt;(); results.values=list; results.count=list.size(); } } else { String constr=constraint.toString(); mObjects= // do what you want to do to populate you suggestion - list //( I call the db and change some values) results.values=mObjects; results.count=mObjects.size(); } return results; } @Override protected void publishResults(CharSequence constraint, FilterResults results) { if (results.count&gt;0) { notifyDataSetChanged(); } else { notifyDataSetInvalidated(); } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload