For posterity, I think this sums up the minimal code need for a Cursor AutoCompleteTextView:
class a extends Activity { AutoCompleteTextView ATFood; class myListAdapter extends CursorAdapter { public myListAdapter(Context context, Cursor c) { super(context, c); } @Override public void bindView(View view, Context context, Cursor cursor) { int columnIndex = cursor.getColumnIndexOrThrow("Col1"); ((TextView) view).setText(cursor.getString(columnIndex)); } @Override public String convertToString(Cursor cursor) { int columnIndex = cursor.getColumnIndexOrThrow("Col1"); return cursor.getString(columnIndex); } @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { final LayoutInflater inflater = LayoutInflater.from(context); final TextView view = (TextView) inflater.inflate (R.layout.search_row, parent, false); int columnIndex = cursor.getColumnIndexOrThrow("Col1"); view.setText(cursor.getString(columnIndex)); return view; } @Override public Cursor runQueryOnBackgroundThread(CharSequence constraint) { if (constraint == null) return myDatabase.searchByTokenReturnName(" "); return myDatabase.searchByTokenReturnName(constraint.toString ()); //returns a cursor with the search results } } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout); Cursor cursor = myDatabase.searchByToken(" "); //returns a cursor with the whole database in it AT = (AutoCompleteTextView) findViewById(R.id.filterEditText); myListAdapter list = new myListAdapter(this, cursor); AT.setAdapter(list); } } On Feb 26, 12:32 am, Will <sem...@gmail.com> wrote: > Thank you for the quick reply. Sorry for my slow reply (Verizon > problems). > > On Feb 24, 11:50 pm, Romain Guy <romain...@google.com> wrote: > > > Yes it's null. You have to specify > > one:http://developer.android.com/reference/android/widget/CursorAdapter.h...) > > > The FilterQueryProvider is a mechanism to let you filter the cursor > > without subclassing CursorAdapter. So either you extend CursorAdapter > > and override runQueryOnBackgroundThread() *or* you supply a > > FilterQueryProvider. > > > On Tue, Feb 24, 2009 at 8:47 PM, Will <sem...@gmail.com> wrote: > > > > I have anAutoCompleteTextViewthat really, really appears to be > > > working. I type and the list pops down as text begins to match what I > > > type, eventually the user can select what he wants and the appropriate > > > value gets passed to the next activity. My adapter is an extended > > > CursorAdapter, not an ArrayAdapter. > > > > My runQueryOnBackgroundThread(CharSequence constraint) takes the > > > constraint and passes it to my own function which does a SQL search > > > for the constraint.toString() and returns a Cursor with the > > > resultset. If the user types in "dog" every row in the table with > > > "dog" a certain column shows up in the dropdown box. This is exactly > > > what I intend. > > > > The issue is that I cannot get a query from FilterQueryProvider(). In > > > fact, calls to getFilterQueryProvider() return null in all cases that > > > I have seen. However, the SDK entry on runQueryOnBackgroundThread > > > states, "The query is provided by a FilterQueryProvider. If no > > > provider is specified, the current cursor is not filtered and > > > returned." The sample code I have seen appear to implement this too. > > > > Since my various calls to getFilterQueryProvider() return null I can > > > only assume no provider is specified and return an ununfilterd cursor > > > (7000+ rows), but my constraint plainly has good data in that should > > > not be ignored. And getFilterQueryProvider() returns null in all > > > cases I have tried. > > > > getFilter does return a Filter > > > I do extend CursorAdapter and implement Filterable in my class > > > > Since I am new I suspect I'm missing something and my emulator will > > > combust any minute. Am I missing something or is this a documentation > > > error? > > > -- > > Romain Guy > > Android framework engineer > > romain...@android.com > > > Note: please don't send private questions to me, as I don't have time > > to provide private support. All such questions should be posted on > > public forums, where I and others can see and answer them > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---