i have listview
more 40 items , want save details on mysql. works first 4-5 items loop stops without error.
string student,obtained_value,max_value; (int i=0;i<liststudent.getchildcount();i++) { view view=liststudent.getchildat(i); studentidtxt=(textview) view.findviewbyid(r.id.student_id_ls); obtainedtxt=(edittext) view.findviewbyid(r.id.obtained); maxtxt=(textview) view.findviewbyid(r.id.max); student=studentidtxt.gettext().tostring(); obtained_value=obtainedtxt.gettext().tostring(); max_value=maxtxt.gettext().tostring(); //updating new mark list array /*hashmap<string,string>studentmark=new hashmap<string,string>(); studentmark.put(tag_student_id,student); studentmark.put(tag_marks_obtained,obtained_value); studentmark.put(tag_marks_max, max_value);*/ //studentmarkslist.add(studentmark); //transform studentmarkslist json //string studentlist=gson.tojson(studentmarkslist); string url_check=domain+"/app/caller.php?action=save_marks&work_id="+workid+"&student="+student+"&obtained="+obtained_value+"&max="+max_value+"&course="+course+"&staff="+staff; string response=caller.makeservicecall(url_check,servicehandler.post); boolean result=false; log.d("response: ", "> " + response); if (response != null) { try { jsonobject jsonobj = new jsonobject(response); // getting json array node serverreply = jsonobj.getjsonarray(tag_check_result); jsonobject c=serverreply.getjsonobject(0); string error_txt= c.getstring(tag_error_txt); string error_code=c.getstring(tag_error_code); string message=c.getstring(tag_message); if(error_txt.equals("success")){ result=true; }else{ result=false; } } catch (jsonexception e) { e.printstacktrace(); } } else { log.e("servicehandler", "couldn't data url"); } }
the commented lines used when tried put them in array send them @ once json, didn't worked.
how can save items listview
without loop stopping?
network i/o slow. need move slow i/o operation out of main thread (ui thread). can try asynctask. helps if can show logcat output.
Comments
Post a Comment