How to parse JSON Array inside another JSON Array and display the Clicked item

馋奶兔 提交于 2019-11-29 18:03:26

The json data has links to three different sized images, it looks to me like you are requesting that all three images are fetched. If you don't want all three, just select the size you want (index 0, 1 or 2) and pull that image only.

JSONArray imageArray = response.getJSONObject(feedKey).getJSONArray(entryKey).getJSONObject(i).getJSONArray(imageKey);
for (int j = 0; j < imageArray.length(); j++) {
   String image = imageArray.getJSONObject(j).getString(labelKey).toString();
   imageUrls.add(image);
   ...
}

Sample Data:

"im:image":[  
               {  
                  "label":"http://is1.mzstatic.com/image/thumb/Purple20/v4/87/35/82/87358231-ce91-3d14-b306-95888c23db3c/mzl.gdgtivnk.png/53x53bb-85.png",
                  "attributes":{  
                     "height":"53"
                  }
               },
               {  
                  "label":"http://is5.mzstatic.com/image/thumb/Purple20/v4/87/35/82/87358231-ce91-3d14-b306-95888c23db3c/mzl.gdgtivnk.png/75x75bb-85.png",
                  "attributes":{  
                     "height":"75"
                  }
               },
               {  
                  "label":"http://is3.mzstatic.com/image/thumb/Purple20/v4/87/35/82/87358231-ce91-3d14-b306-95888c23db3c/mzl.gdgtivnk.png/100x100bb-85.png",
                  "attributes":{  
                     "height":"100"
                  }
               }

Update 9/13/2016

Based on what I think you are after, I still think your problem is in your nested for loop in the jsonAppShowData() method. Though you do appear to pass some sort of ID extra in from the previous activity, I don't see you filtering on that item ID anywhere in the for loop. You need to restrict the outer for loop to only the item you wish to show.

For the image scaling issue, it may either be how your layout is setup or you can try some of the Picasso resize calls.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!