java - Custom Adapter No Id Value -


hi im trying populate listview baseadapter , when selected on listview wrong id propagated.

here adapter

public class mycustombaseadapter extends baseadapter {     private static arraylist<custom> alist;      private layoutinflater inflat;      public mycustombaseadapter(context context, arraylist<custom> results) {         alist = results;         inflat = layoutinflater.from(context);     }      public int getcount() {         return alist.size();     }      public object getitem(int position) {         return alist.get(position);     }      public long getitemid(int position) {         return position;     }      public view getview(int position, view convertview, viewgroup parent) {         viewholder holder;         if (convertview == null) {             convertview = inflat.inflate(r.layout.suspect_list, null);             holder = new viewholder();             holder.txtname = (textview) convertview.findviewbyid(r.id.suspect_name);             holder.txtsex = (textview) convertview.findviewbyid(r.id.suspect_sex);             holder.txtid = (textview) convertview.findviewbyid(r.id.suspect_id);              convertview.settag(holder);         } else {             holder = (viewholder) convertview.gettag();         }          holder.txtname.settext(alist.get(position).getname());         holder.txtsex.settext(alist.get(position).getsex());         holder.txtid.settext(alist.get(position).getid());          return convertview;     }      static class viewholder {         textview txtname;         textview txtsex;         textview txtid;     }  } 

any can provide great more code can availble upon request

your getitemid() should return id. should this->

public long getitemid(int position) {         return alist.get(position).getid();     } 

assuming id long, if not use -> long.parselong(alist.get(position).getid());


Comments