Hi,
I have been trying to get my head around this issue, but can't
figure out. I have an AutoCompleteTextView which I am populating from
a custom adapter that extends CursorAdapter. The data source for the
cursor adapter is a table(columns : name and _id) in my database. I
have put debug statements in every method in My Custom Adapter class
that extends CursorAdapter, but none of the methods that I have
overridden like newView(), convertToString(), bindView() get called,
EXCEPT runQueryOnBackgroundThread() which gets called as I type my
input into the text view. Here is my code for your reference :
Inner Class :
private class myCursorAdapter extends CursorAdapter
{
Context context = null;
private int columnIndex;
public myCursorAdapter(Context context, Cursor c, int
col) {
super(context, c);
this.columnIndex = col;
}
@Override
public void bindView(View view, Context context, Cursor
cursor) {
Log.d("MainActivity", " bindView:"+cursor.getString
(columnIndex));
((TextView) view).setText(cursor.getString
(columnIndex));
}
@Override
public String convertToString(Cursor cursor) {
Log.d("MainActivity", " convertToString:"+cursor.getString
(columnIndex));
return cursor.getString(columnIndex);
}
@Override
public View newView(Context context, Cursor cursor,
ViewGroup parent)
{
Log.d("MainActivity", "
newView:*************************");
final LayoutInflater inflater = LayoutInflater.from
(context);
final TextView view = (TextView) inflater.inflate(
android.R.layout.simple_dropdown_item_1line,
parent, false);
return view;
}
@Override
public Cursor runQueryOnBackgroundThread(CharSequence
constraint)
{
Log.d("MainActivity","runQueryOnBackgroundThread");
if (constraint != null){
return MainActivity.this.getItemsAsCursor
(constraint.toString());
}else{
return MainActivity.this.getItemsAsCursor("All");
}
}
}
This is how I instantiate and set the adapter (From a class that
extends ListActivity) :
Cursor cursor = getItemsAsCursor("All");
myCursorAdapter adapter = new myCursorAdapter
(this.getApplicationContext(), cursor, 0);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById
(R.id.edit);
textView.setThreshold(2);
textView.setAdapter(adapter);
Am I doing something wrong? Any help is highly appreciated.
Thanks
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---