moayed ayasaa moayed ayasaa - 1 year ago 128
JSON Question

parsing JsonArray to Picasso library

i have this Json Data

and i prasing the data in in this json to this ,,

enter image description here

now i want when user click on the image of the application open another activty which have a recyceler view and display the images in the "im:image" json array in the json ! this code give to me all images ,but i wont just the image thats i clicked any idea ??

this is my Module

public class AppShowModule{

private List<String> Allimage = new ArrayList<String>();
public List<String> getAllimage() {
return Allimage;}
public void setAllimage(List<String> allimage) {
Allimage = allimage;}

the recycler view adapter

public class ImageListAdapter extends RecyclerView.Adapter<ImageListAdapter.ViewHolder> {
List<AppShowModule> appShowModules;
List<AppShowModule> imageUrls ;

Context context;
public ImageListAdapter(List<AppShowModule> appShowModules, Context context){
this.appShowModules = appShowModules;
this.context = context;}
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from( parent.getContext() ).inflate( R.layout.imagelayout, parent,false );
ViewHolder viewHolder = new ViewHolder( v );
return viewHolder;}
public void onBindViewHolder(ViewHolder holder, int position) {
final AppShowModule appShowModule = appShowModules.get( position );

public int getItemCount() {
return appShowModules.size();
class ViewHolder extends RecyclerView.ViewHolder {
public ImageView appImage;
public ViewHolder(View itemView) {
appImage = (ImageView) itemView.findViewById(;

and this is the fragment

public class ImageListFragment extends Fragment {

List<AppShowModule> appShowModules;
Context context;
List<AppShowModule> imagesModule;
RecyclerView AppRecyclerView;
ImageView Imageview;
RecyclerView.Adapter imageRecyclerViewadapter;
List<String> imageUrls;
String feedKey = "feed";
String entryKey = "entry";
String nameKey = "im:name";
String imageKey = "im:image";
String labelKey = "label";
String artistKey = "im:artist";
String contentTypeKey = "im:contentType";
String attribueKey = "attributes";
String rightsKey = "rights";
String categoryKey = "category";
String relaseDateKey = "im:releaseDate";
String linkKey = "link";
String hrefKey = "href";
String summaryKey = "summary";
String jsonUrl = "";
RequestQueue requestQueue;
private RecyclerView.LayoutManager mLayoutManager;
public ImageListFragment() {
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_image_list, container, false);
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
AppRecyclerView = (RecyclerView) getView().findViewById(;
imagesModule = new ArrayList<>();
appShowModules = new ArrayList<>();
imageUrls = new ArrayList<>();
public void JsonAppShowData() {
final JsonObjectRequest jsonObjectRequest = new JsonObjectRequest( jsonUrl, new Response.Listener<JSONObject>() {
public void onResponse(JSONObject response) {
try {

JSONArray jsonArray = response.getJSONObject("feed").getJSONArray( "entry" );
AppShowModule appShowModule = new AppShowModule();
for (int i = 0; i < jsonArray.length(); i++) {

String image = response.getJSONObject(feedKey).getJSONArray(entryKey).getJSONObject(i).getJSONArray(imageKey).getJSONObject(0).getString(labelKey).toString();
imageRecyclerViewadapter = new ImageListAdapter(appShowModules,getContext());
} catch (JSONException e) {

}, new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {
Log.e( "LOG", error.toString() );
} );
requestQueue = Volley.newRequestQueue( getContext() );
mLayoutManager = new GridLayoutManager( getContext().getApplicationContext(),3);
AppRecyclerView.setLayoutManager(mLayoutManager); }}

Answer Source

Here you are fetching first image from each array by doing following


whereas you need to fetch all the images related to selected image from the array so iterate your array on the inner image array im:image, not on outer main array entry. follow these steps

  1. Whenever you click on the image item then get the id of that item.
  2. iterate on the outer array entry and check if the clicked items id matches in the array entry.
  3. when it matches id then iterate on inner array im:immage and store those images in your list. And apply that list to your recyclerview.

Hope this helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download