android - How to access invidual json objects from a json array? -


i have following response, , want display eqid's in invidual textview's, don't know how achive this, below snippet code , response data server , display in textview.
can me this?

{   "earthquakes":[     {       "eqid":"c0001xgp",      },     {       "eqid":"c000905e",      },     {       "eqid":"2007hear",      },     {       "eqid":"c00090da",      },     {       "eqid":"2007aqbk",      },     {       "eqid":"2007hec6",      },     {       "eqid":"a00043nx",      },     {       "eqid":"2010utc5",      },    ] } 

code

   servicehandler sh = new servicehandler();     jsonstr = sh.makeservicecall(user_url, servicehandler.get);     log.d("response: ", "> " + jsonstr);      try{         jsonobject json = new jsonobject(jsonstr);         jsonarray items = json.getjsonarray("product");          parent_layout = (relativelayout)findviewbyid(r.id.rl);         for(int =0; i<items.length(); i++){                textview textview = new textview(this);             textview.settext(items.getjsonobject(i).getstring(user_name));              parent_layout.addview(textview);         } 

try{      jsonobject json = new jsonobject(jsonstr);      jsonarray items = json.getjsonarray("earthquakes");        for(int =0; i<items.length(); i++){          textview t=new textview(context);          t.settext(items.getjsonobject(i).getstring('eqid'));          parentlayout.addview(t);      }  }catch(jsonexception e){      e.printstacktrace();  }


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -