I tried to parse a collection of image to recyclerview
as gridview
using Picasso
library but i cannot make it work
Note : i dont h
You would need a List
to save urls to be viewed by picasso, no need for special object for that. To solve it, change your json parsing code to
try {
JSONArray entries = response.getJSONObject("feed").getJSONArray("entry");
int count = entries.length();
for (int i = 0; i < count; i++) {
JSONObject imageJson = entries.getJSONObject(i).getJSONObject("im:image");
// in case you want to get image with height 53
String imageUrl = imageJson.getJSONObject("0").getString("label");
// String imageUrl = imageJson.getJSONObject("1").getString("label"); height 75
// String imageUrl = imageJson.getJSONObject("2").getString("label"); height 100
// add urls to the list
imageUrls.add(imageUrl);
}
} catch (JSONException e) {
e.printStackTrace();
}
then change your adapter to have a List
instead of List
and pass the parsed list to the constructor. Finally in your adapter onBindViewHolder()
change the picasso code to
Picasso.with(context).load(imageUrls.get(position)).into(holder.appImage);
hope it helps