我获取JSON数据如下如何在滚动视图中放置不同的JSON对象?
JsonObjectRequest jor = new JsonObjectRequest(url, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try{
JSONArray ja = response.getJSONArray("results");
for(int i=0; i < ja.length(); i++){
JSONObject jsonObject = ja.getJSONObject(i);
int id = Integer.parseInt(jsonObject.optString("id").toString());
String url = jsonObject.getString("resLink");
String resType= jsonObject.getString("resType");
String name = jsonObject.getString("resName");
data += "ResType= "+resType +" \n URl= "+ url +" \n id = "+ id + "\n Name = "+ name+"\n\n\n" ;
// data +=videoUrl+url;
}
output.setText(data);
}catch(JSONException e){e.printStackTrace();}
}
我只是获取JSON数据和表示在文本它view.What我需要的是根据resType.Means显示那些在水平滚动视图所有restype“图像”将在图像滚动视图和视频中,视频将会滚动视图在同一屏幕
你好,你的代码我可以说,data + =“ResType =”+ resType +“\ n URl =”+ url +“\ n id =”+ id +“\ n Name =”+ name +“\ n \ n \ n“;将添加数据字符串中的所有数据,您不区分基于资源类型的所有数据,尝试获取四个不同的数据字符串,并区分所有数据并将它们添加到每个个体中,并在textview中显示它们。 –
把它们当成你正在做的简单的JSON与其他视图。 –
好吧@Silvans让我试试... –