android - Create a arraylist from output of a for loop -
i trying data set [{a,b,c,d} {e,f,g,h}]
i'm getting [a,b,c,d,e,f,g,h]
using below mentioned code. should achieve that. highly appreciated. i'm new android please kind enough answer me. in advance
list<string> cartitementitylist = new arraylist<string>(); (int = 0; < mcartlist.size(); i++) { if (!mcartlist.isempty()) { product product = mcartlist.get(i); int quantity = product.quantity; double subtotal = product.subtotal; cartitementity = product.items; (int j = 0; j < cartitementity.size(); j++) { item item = cartitementity.get(j); submenucode = item.submenucode; mainmenucode = item.mainmenucode; price = item.price; cartitementitylist.add(mainmenucode); cartitementitylist.add(string.valueof(price)); cartitementitylist.add(string.valueof(quantity)); cartitementitylist.add(submenucode); } } system.out.println("cartitementitylist " + cartitementitylist); }
i able achieve using json serialization , answer
jsonobject jsonobj = new jsonobject(); jsonobj.put("mainmenucode", item.getmainmenucode()); jsonobj.put("price", item.getprice()); jsonobj.put("quantity", product.getquantity()); jsonobj.put("submenucode", item.getsubmenucode()); string = jsonobj.tostring(); cartiddtementitylist.add(a);
Comments
Post a Comment