android - Display json data into a editext -



android - Display json data into a editext -

hi have functions gets json array , displays info listview, want display result on edittext how modify can help me. thanks. know need alter on postexecute method dont know how it

/** * background async task load product making http request * */ class loadallproducts extends asynctask<string, string, string> { /** * before starting background thread show progress dialog * */ @override protected void onpreexecute() { super.onpreexecute(); } /** * getting products url * */ protected string doinbackground(string... args) { // building parameters seek { list<namevaluepair> params = new arraylist<namevaluepair>(); params.add(new basicnamevaluepair("id", teste)); // getting json string url jsonobject json = jparser.makehttprequest(url_all_products, "post", params); // check log cat json reponse log.d("all products: ", json.tostring()); // checking success tag int success = json.getint(tag_success); if (success == 1) { // products found // getting array of products products = json.getjsonarray("estab"); // looping through products (int = 0; < products.length(); i++) { jsonobject c = products.getjsonobject(i); // storing each json item in variable string design = c.getstring(tag_design); // creating new hashmap hashmap<string, string> map = new hashmap<string, string>(); // adding each kid node hashmap key => value map.put(tag_design, design); // adding hashlist arraylist productslist.add(map); } } else { // no products found // launch add together new product activity } } grab (jsonexception e) { e.printstacktrace(); } homecoming null; } /** * after completing background task dismiss progress dialog * **/ protected void onpostexecute(string file_url) { // dismiss dialog after getting products pdialog.dismiss(); // updating ui background thread runonuithread(new runnable() { public void run() { /** * updating parsed json info listview * */ adapter = new simpleadapter( linhas_pesagem.this, productslist, r.layout.list_lin_items, new string[] { tag_id, tag_estab, tag_data, tag_hora, tag_qtd, tag_idestab}, new int[] { r.id.id, r.id.id_estab, r.id.dt, r.id.hr, r.id.quantidade, r.id.idestab}); // updating listview setlistadapter(adapter); } }); } }

you can create fellow member variable (jsonobject jsonoutput) in asynctask object , assign json it. in onpostexecute utilize

edittext.settext(jsonoutput.tostring)

hope helps

android json

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -