I want to populate List Dialog with values from database. I am using this code(where c is a cursor obtained by Query "select * from tbl" )
ab.setCursor(c, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
},c.getColumnName(0));
But it is showing exception java.lang.IllegalArgumentException: column'_id' does not exist.But this column is present in my table.
I have seen only example of setCursor on stackoverflow to use set cursor like this:
builder.setCursor(c, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
c.moveToPosition(which);
int idWeWant = c.getInt(c.getColumnIndexOrThrow(STRING_ID_WE_WANT));
//you can make another dialog here using the same method
}
});
which is marked right but it is 2 argument passing method and in my IDE setCursor() is 3 argument passing so how can it be right.. Help me with the correct implementation of setCursor and also tell me how to use setSingleChoiceItems(cursor, checkedItem, labelColumn, listener) as same illegel state exception is shown in this method(using labelColumn as c.getColumnName(0)).
Thanx in advance.
Aucun commentaire:
Enregistrer un commentaire