android - The ListView is showing duplicate data -


this how display listview, i'm not sure whether correct method or not showing listview this. problem listview have duplicate data when "condimentdescription" having more 1 data, following code, kindly advise. the listview show this, not want.
this want

public list<orderlist> getorderlist() {             list<orderlist> orderlist = new arraylist<orderlist>();              try {                 string selectquery = "select t2.id,t2.productcode,t2.price,t2.qty,t3.description,t4.condimentdescription tempcs t1 \n" +                         "left outer join tempcsdetail t2 on t1.docno=t2.docno\n" +                         "left outer join mproduct t3 on t2.productcode=t3.code \n" +                         "left outer join tempcscondiment t4 on t2.seqno=t4.seqno"+                         "where t1.docno=" + tablepagedocno + "\n";                  sqlitedatabase db1 = db.getreadabledatabase();                 cursor cursor = db1.rawquery(selectquery, null);                  if (cursor.movetofirst()) {                         {                             orderlist list = new orderlist();                            list.setproductcode(cursor.getstring(cursor.getcolumnindex("productcode")));                             list.setprice(double.parsedouble(cursor.getstring(cursor.getcolumnindex("price"))));                             list.setqty(cursor.getstring(cursor.getcolumnindex("qty")));                             list.setdescription(cursor.getstring(cursor.getcolumnindex("description")));                             list.set_id(integer.parseint(cursor.getstring(cursor.getcolumnindex("id"))));              //this more 1 row in sqlite database                               list.setcondimentdescription(cursor.getstring(cursor.getcolumnindex("condimentdescription")));                                     orderlist.add(list);                                 } while (cursor.movetonext());                             }              }catch(exception e){             }          return orderlist;     } 

adapter list

public class  orderlistadapter extends baseadapter {         layoutinflater minflater;         public orderlistadapter() {             minflater = layoutinflater.from(listfragmentactivity.this);         }         @override         public int getcount() {             return orderlist.size();         }         @override         public object getitem(int position) {             return null;         }         @override         public long getitemid(int position) {             return position;         }         @override         public view getview(final int position, view convertview, viewgroup parent) {             if (convertview == null) {                 convertview = minflater.inflate(r.layout.listproduct1, null);             }              final textview _id = (textview) convertview.findviewbyid(r.id.proid);             _id.settext("" + orderlist.get(position).get_id());             final string proid = _id.gettext().tostring();              final textview productcode = (textview) convertview.findviewbyid(r.id.productcode);             productcode.settext("" + orderlist.get(position).getproductcode());              final textview description = (textview) convertview.findviewbyid(r.id.description);             description.settext("" + orderlist.get(position).getdescription());              final textview price = (textview) convertview.findviewbyid(r.id.price);         price.settext("" + string.format("%.2f",orderlist.get(position).getprice()));         final double price= double.valueof(price.gettext().tostring());          final textview qty = (textview) convertview.findviewbyid(r.id.qty);         qty.settext("" + orderlist.get(position).getqty());          final textview condimentdescription=(textview)convertview.findviewbyid(r.id.condimentdescription);         condimentdescription.settext("" + orderlist.get(position).getcondimentdescription());          notifydatasetchanged();         return convertview;     } } 

every time should create new object of orderlist in do-while loop . remove top of function .


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -