android - binding adapter to list view -
if(cur.movetofirst()) { do{ int nameidx=cur.getcolumnindexorthrow(contactscontract.contacts.display_name); int ididx=cur.getcolumnindexorthrow(contactscontract.contacts.has_phone_number); string strname=cur.getstring(nameidx); string strid=cur.getstring(ididx); if(strid.equals("0")) continue; toast.maketext(this,"contact name: "+strname, toast.length_long).show(); names.add(strname); //result[cur.getposition()]=strname+"("+strid+")"; }while(cur.movetonext()); adapter=new arrayadapter<string>(this, r.layout.list_view_item, names); setlistadapter(adapter);
this code , getting error @ setlistadapter(adapter) setlistadapter undefined. please me in resolving error.
you need have object of listview
listview lv = (listview) findviewbyid(r.id.lv);
then set adapter listview object
lv.setadapter(adapter);
setlistadapter()
works when class extends listactivity
Comments
Post a Comment