android - How to display data? -


i using method call service in application.

 protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.next);     string url = "url";      aquery maquery = new aquery(next.this);     maquery.ajax(url, string.class, new ajaxcallback<string>() {         @override         public void callback(string url, string data, ajaxstatus status) {             super.callback(url, data, status);             if (buildconfig.debug) {                 log.d("###$request url", url + "");                 log.d("###$response ", data + "");                 log.d("###$status message : ", status.getmessage() + "");                 log.d("###$status code : ", status.getcode() + "");              }               if (null != data && status.getcode() != -101) {                  string stringdata = "" + data;                 try {                       jsonobject json = new jsonobject(stringdata);                      string comp_req_id = json.getstring("comp_req_id");                     string companyname = json.getstring("companyname");                     string comp_req_type = json.getstring("comp_req_type");                     string name  = json.getstring("name ");                      myawesometextview.settext("comp_req_id: " + comp_req_id + "\n" + "companyname:" + companyname + "\n" + "comp_req_type: " + comp_req_type + "\n" + "name : " + name);                  } catch (jsonexception e) {                     myawesometextview.settext("" + e);                 } 

but data coming server not getting display on phone screen. data got service given below:

              [{"name":null,"positionname":null,"dateofevent":null,"evetnid":0,"hetid":0,"eventdate":null,"comp_req_id":9714,"comp_req_type":"intership","jobtitle":"administrator","companyname":"jensor's international (ltd).","reqqualification":"","degreename":"b.e/b.tech,m.c.a,m.b.a,b.a,b.a.m.s,b.com,b.s.w","post_status":1,"eventdate":"21/06/2016","jobsorinternships":null},{"name":null,"positionname":null,"dateofevent":null,"evetnid":0,"hetid":0,"eventdate":null,"comp_req_id":9713,"comp_req_type":"intership","jobtitle":"junior counselor","companyname":"jensor's international (ltd).","reqqualification":"","degreename":"b.e/b.tech,m.c.a,m.b.a,b.b.m,b.com,b.f.a","post_status":1,"eventdate":"21/06/2016","jobsorinternships":null} 

how display it.

you should use jsonarray parse result

jsonarray rootarray = new jsonarray(jsonstring); int len = rootarray.length(); for(int = 0; < len; ++i) {     jsonobject json = rootarray.getjsonobject(i);     string comp_req_id = json.getstring("comp_req_id"); } 

or can use gson library parse result you. recommend post example how query data asp.net web api.

i think should make question clear because i'm not sure if have problem getting data or showing data ui.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -