I use this code:
AutoCompleteTextView autorif = (AutoCompleteTextView) findViewById(R.id.autoComplete);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, db.getWhere());
autorif.setAdapter(adapter);
autorif.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l)
{
val = (String) adapterView.getItemAtPosition(i);
}
}
all is ok, i read all value in my autocomplete with this function:
public List<String> getWhere()
{
SQLiteDatabase db=helper.getReadableDatabase();
Cursor crs=db.query("where", null, null, null, null, null, null);
List<String> res=new ArrayList<String>();
while(crs.moveToNext())
{
String tmp=crs.getString(crs.getColumnIndex("rif_name"));
res.add(tmp);
}
crs.close();
return res;
}
variable "val" contains a good value of rif_name.
But in my table (where) I have other value (_id, rif_name, position). How can I "extract" or return other value, when i click on item of autocomplete? Thanks!
Aucun commentaire:
Enregistrer un commentaire