I finally found how to do it!!!
Jope this is useful for someone:
In the main class:
mAcReason = ((AutoCompleteTextView)
findViewById(R.id.ac_registerevent_reason));
ContactListAdapter adapter = new ContactListAdapter(this, mCursor);
this.mAcReason.setAdapter(adapter);
public static class ContactListAdapter extends CursorAdapter
implements Filterable {
public ContactListAdapter(Context context, Cursor c) {
super(context, c);
Log.d("exp", "******************* A VER EHJEE
*****************");
mDb = new Database(context);
mDb.open();
Log.d("exp", "******************* A VER PUES 100
*****************");
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup
parent) {
final LayoutInflater inflater =
LayoutInflater.from(context);
final TextView view = (TextView) inflater.inflate(
android.R.layout.simple_dropdown_item_1line, parent,
false);
Log.d("exp", "******************* A VER 100
*****************");
view.setText(cursor.getString(2));
Log.d("exp", "******************* A VER PUES 150
*****************");
return view;
}
@Override
public void bindView(View view, Context context, Cursor cursor)
{
Log.d("exp", "******************* A VER 200
*****************");
((TextView) view).setText(cursor.getString(2));
}
@Override
public String convertToString(Cursor cursor) {
Log.d("exp", "******************* A VER 300
*****************");
return cursor.getString(2);
}
@Override
public Cursor runQueryOnBackgroundThread(CharSequence
constraint) {
if (getFilterQueryProvider() != null) {
Log.d("exp"+constraint, "******************* A VER PUES
800 *****************");
return getFilterQueryProvider().runQuery(constraint);
}
StringBuilder buffer = null;
String[] args = null;
/*if (constraint != null) {
buffer = new StringBuilder();
buffer.append("UPPER(");
Log.d("exp", "******************* A VER 400
*****************");
buffer.append(Database.KEY_REASON);
Log.d("exp", "******************* A VER PUES 900
*****************");
buffer.append(") GLOB ?");
args = new String[]
{ constraint.toString().toUpperCase() + "*" };
//args = "g";
Log.d("exp"+constraint, "******************* A VER
PUES 800 *****************");
}*/
Log.d("exp", "******************* A VER 500
*****************");
String where = "";
if (constraint != null) where =
constraint.toString();
Log.d("exp"+where, "******************* A VER 500
*****************");
Cursor cur = mDb.fetchCustomEvents("expense", "reason
like '" + where + "%'");
Log.d("TOTAL="+cur.getCount(), "******************* A VER
500 *****************");
return cur;
}
private Database mDb;
}
private static final String[] PEOPLE_PROJECTION = new String[] {
Database.KEY_REASON,
Database.KEY_VALUE,
Database.KEY_TAX
};
On Nov 6, 9:49 pm, "Juan David Trujillo C." <[EMAIL PROTECTED]>
wrote:
> Hi all!!
>
> I want to create an autocomplete that gets its information from a
> database query. I have a database method that returns the Cursor
> (with name, value and date fields) I need, but I dont know how to
> actually fill it, so it works as expected as the Contacts API
> demo:http://code.google.com/android/samples/ApiDemos/src/com/example/andro...
>
> I want the autocomplete to show the name field from the database
> query.
>
> I read the following thread, but still haven't been able to figure it
> out.
>
> http://groups.google.com/group/android-developers/browse_thread/threa...
>
> I have to use the methods:
> runQueryOnBackgroundThread, convertToString, among others and extend
> extends SimpleCursorAdapter, but I still don't know how to actually
> use it.
>
> Appreciate any help provided!!!
>
> Best regards,
>
> Juan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" 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-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---