android - How to get values from the selected item in a list view? -
this code far. working shows first value have in listview , not selecting item user. please halp me this. important.
unitlistview.setchoicemode(abslistview.choice_mode_single); unitlistview.setonitemclicklistener(new adapterview.onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { // selected item textview t1 = (textview) findviewbyid(r.id.lbllunitname); string name=t1.gettext().tostring(); // string a= (string) unitlistview.getitematposition(position); // touchpressed=position; toast.maketext(getapplicationcontext(), "selected item :" +name, toast.length_short).show(); } });
update code follows , try ;
unitlistview.setchoicemode(abslistview.choice_mode_single); unitlistview.setonitemclicklistener(new adapterview.onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view,int position, long id) { textview t1 = (textview) findviewbyid(r.id.lbllunitname); string name=string.valuesof(position); toast.maketext(getapplicationcontext(), "selected item :" +name, toast.length_short).show(); } });
Comments
Post a Comment