I have the following response, and I want to display all eqid
's in invidual TextView
's, but I don't know how to achive this,
below is my snippet code and response to get data from the server and display in textview.
Can anyone help me with 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 i =0; i<items.length(); i++){
TextView textView = new TextView(this);
textView.setText(items.getJSONObject(i).getString(USER_NAME));
parent_layout.addView(textView);
}