我獲取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讓我試試... –