android - How to pass three string from for loop -
i have made program 'item','qty','rate' have them 3 in string array need them upload in mysql values reapeating several times in database.
here code:
string items[] = itemsf.split("\n"); string qtys[] = qtyv.split("\n") string rates[] = ratef.split("\n"); (final string r : rates) { (final string : items) { toast.maketext(billgenerating.this, it, toast.length_short).show(); (final string qt : qtys) { toast.maketext(billgenerating.this, qt, toast.length_short).show(); class addbilldetails extends asynctask<void, void, string> { progressdialog loading; @override protected void onpreexecute() { super.onpreexecute(); loading = progressdialog.show(billgenerating.this, "adding...", "wait...", false, false); } @override protected void onpostexecute(string s) { super.onpostexecute(s); loading.dismiss(); toast.maketext(billgenerating.this, s, toast.length_long).show(); } @override protected string doinbackground(void... v) { hashmap<string, string> params = new hashmap<>(); params.put(key_bill_items, it); params.put(key_bill_qty, qt); params.put(key_bill_rate, r); requesthandler rh = new requesthandler(); string res = rh.sendpostrequest(config.bill_details_local_job, params); return res; } } addbilldetails ae = new addbilldetails(); ae.execute(); } } } return sum; }
i have made mistake in looping process pls me.
assuming items
, qtys
, rates
have same length
.
string[] items = itemsf.split("\n"); string[] qtys = qtyv.split("\n"); string[] rates = ratef.split("\n"); for(int = 0; < items.length; i++){ addbilldetails ae = new addbilldetails(); ae.execute(items[i], qtys[i], rates[i]); }
addbilldetails.class
class addbilldetails extends asynctask<string, string, string> { progressdialog loading; @override protected void onpreexecute() { super.onpreexecute(); loading = progressdialog.show(billgenerating.this, "adding...", "wait...", false, false); } @override protected void onpostexecute(string s) { super.onpostexecute(s); loading.dismiss(); toast.maketext(billgenerating.this, s, toast.length_long).show(); } @override protected string doinbackground(string... v) { hashmap<string, string> params = new hashmap<>(); params.put(key_bill_items, v[0]); params.put(key_bill_qty, v[1]); params.put(key_bill_rate, v[2]); requesthandler rh = new requesthandler(); return rh.sendpostrequest(config.bill_details_local_job, params); } }
Comments
Post a Comment