android - can't getting data from cursor adapter -
i have listview
(in activity
, not in listactivity
) utilizes custom cursor adapter data local db , show them inside listview
.
lv.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view view, int position, long id) { log.i(tag, "position = " + position); log.i(tag, "id : " + id)); } });
assume database columns following :
id, name, surname, dob, height, gender, placeofbirth, maritalstatus.
however, showing in listview (row.xml) name , surname. whenever user clicks on row in list, want retrieve rest of data too, example, id, or gender of row clicked.
the issue that, not showing info db row in list, however, when user presses on list need retrieve of data list. how can here ?
the below method not work, because not in listactivity, , activity.
public void onlistitemclick(listview l, view v, int position, long id) { super.onlistitemclick(l, v, position, id); cursor c = ((simplecursoradapter)l.getadapter()).getcursor(); c.movetoposition(position); //get data... }
the arg0
parameter in onitemclicklistener
is listview
. however, can
lv.setonitemclicklistener(new onitemclicklistener() { @override public void onitemclick(adapterview<?> arg0, view view, int position, long id) { // cursor adapter, moved position cursor cursor = (cursor) mcursoradapter.getitem(position) //get data... } });
Comments
Post a Comment