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 can't load multiple images in single ImageView
so try to load each image in different ImageView
, As I have observerd there are fixed 3 number of images in each module so add 3 ImageViews
in your xml layout and apply images separately.
You would need a List<String> imageUrls
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<String> imageUrls
instead of List<ImagesModule> imagesModule
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