Hello all, could you please help me look and this code and tell me what am doing wrong. I have a listview that is populated through a Cursor Adapter but when i click on a row, it returns back the row above it and not the target row clicked. and if i click on the first row, it just crashes with a "cursor out of bound exception". Here is the code:
and this is the database method that is being called:
i have tried changing it to a OnListItemSelected() but nothing happens.I am using the new view and bind view method on the cursor adapter. Please Help.
Code:
public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) {
c = adapter.retrieveRow(rowId);
Intent edit = new Intent(this,Item.class);
edit.putExtra(DBAdapter.KEY_ID, rowId);
edit.putExtra(DBAdapter.NAME, c.getString(c.getColumnIndex(DBAdapter.NAME)));
edit.putExtra(DBAdapter.START_DATE, c.getString(c.getColumnIndex(DBAdapter.START_DATE)));
startActivityForResult(edit, ACTIVITY_EDIT);
}
and this is the database method that is being called:
Code:
public Cursor retrieveRow(long rowId) {
String[] resultColumns = new String[] {NAME,START_DATE};
Cursor row = db.query(true,DATABASE_TABLE, resultColumns, KEY_ID +"=" +rowId, null, null, null, null,null);
if(row != null){
row.moveToFirst();
}
return row;
}
i have tried changing it to a OnListItemSelected() but nothing happens.I am using the new view and bind view method on the cursor adapter. Please Help.