Hi I have an AutoCompleteTextView which uses a CursorAdapter to read
entries from the database
Funny thing is If I type d I get the list (dam , dog , drain ,
duck) which is correct then
if I type r (to now have dr) I should get drain but the drop
down still shows dam the first entry from d
yet If I select this first drop down entry then the
AutocompleteTextView text field shows drain
which is correct.
Why does the drop down list not show correctly ?
I have also noticed that If I have more than 12 entries in the drop down
list It shows the first 8 then when I scroll it shows the first 8 again
But like above if I select the 14 entry the text field is correct.
Thanks In advance
Here is the CursorAdapter
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
final LinearLayout ret = new LinearLayout(context);
final LayoutInflater inflater = LayoutInflater.from(context);
TextView name = (TextView)
inflater.inflate(android.R.layout.simple_dropdown_item_1line, parent,
false);
ret.setOrientation(LinearLayout.VERTICAL);
int nameCol = cursor.getColumnIndex(DBAdapter.KEY_CLIENT_NAME);
name.setText( cursor.getString(nameCol) );
ret.addView(name, new
LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT ,
LayoutParams.WRAP_CONTENT));
return ret;
}
@Override
public void bindView(View v, Context context, Cursor c) {
int nameCol = c.getColumnIndex(DBAdapter.KEY_CLIENT_NAME);
String name = c.getString(nameCol);
TextView nameText = (TextView) v.findViewById(R.id.invClient);
if (nameText != null) {
nameText.setText(name);
}
}
@Override
public String convertToString(Cursor cur) {
int nameCol = cur.getColumnIndex(DBAdapter.KEY_CLIENT_NAME);
String name = cur.getString(nameCol);
return name;
}
@Override
public Cursor runQueryOnBackgroundThread(CharSequence constraint) {
StringBuilder buffer = null;
if (constraint != null) {
if ( constraint.equals("*") ) {
return DataB.getClientList();
} else {
buffer = new StringBuilder();
buffer.append("UPPER(name) LIKE '");
buffer.append( constraint.toString().toUpperCase() +
"%' ");
return DataB.getClientList(buffer.toString());
}
}
return DataB.getClientList("");
}
public Cursor getClientList() {
return myDB.query(DATABASE_TABLE_CLIENT, new String[] {
KEY_CLIENT_NUMB, KEY_CLIENT_NAME }, null, null, null, null,
KEY_CLIENT_NAME);
}
--
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