I have a dialog that shows a ListView of certain items like this
d = new Dialog(this);
d.setContentView(R.layout.dialog_layout);
d.setTitle("Select Bowler " + String.valueOf(bakerList.size()+1));
ListView lv3 = (ListView)d.findViewById(R.id.dialog_list);
Cursor c3 = getContentResolver().query(TeamBowlers.CONTENT_URI,new String[] {TeamBowlers.ID,TeamBowlers.SUB,TeamBowlers.BOWLER_ID,TeamBowlers.CAPTAIN}
,TeamBowlers.TEAM_ID + "=?",new String[] {String.valueOf(teamSelectedID)},TeamBowlers.POSITION + " ASC");
if(c3.moveToFirst() && c3 != null){
SimpleCursorAdapter adapter2 = new ImageAdapter(this,R.layout.row,c3
,new String[] {TeamBowlers.ID,TeamBowlers.SUB,TeamBowlers.BOWLER_ID},new int[] {R.id.icon,R.id.bowler_txt,R.id.bowler_txt2});
lv3.setAdapter(adapter2);
lv3.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> arg0, View v,int position, long id) {
bakerList.add(id);
updateName(id);
}
});
d.show();
}
problem is that when I click on an item in the list the ID that gets returned is not the id from the database it just returns the index basically.
why is it not binding my “_id” column of my database?
I guess it is not true. That
idin theonItemClickis actually therow idin list view, it is not theidfrom yourcursorIf you want the row data you can do some thing like this in
onItemClick