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

后端 未结 1 712
半阙折子戏
半阙折子戏 2020-12-22 12:46

hello i have this Json Data a link

and i parsing it like that

when i click into the image i want to parsing the JsonArray for the image to piccaso

1条回答
  •  [愿得一人]
    2020-12-22 12:46

    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.

    0 讨论(0)
提交回复
热议问题