I have Navigation Spinner on my Activity's ActionBar. It was populated by data from SQLite Database using SimpleCursorAdapter. I have done this using following code
String query="select rowid _id, vehicleName from vehiclesTable";
try{
Cursor c1=db.rawQuery(query,null);
if (c1.getCount()>0){
while (c1.moveToNext()){
adapter=new SimpleCursorAdapter(this,android.R.layout.simple_list_item_1, c1,new String[]{"vehicleName"},new int[]{android.R.id.text1});
}
}
}catch (SQLiteException e){
Toast.makeText(MainPage.this,e.toString(),Toast.LENGTH_SHORT).show();
}
actionBar=getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setListNavigationCallbacks(adapter,this);
Now I have to get the selected items text and display it in Toast. I don't know how to do that. Anyone who knows please help me with it.
Aucun commentaire:
Enregistrer un commentaire