Skip to content Skip to sidebar Skip to footer

How To Pass Json Array Using Json Object

GridView contains Categories, and when I do tap on any of the GridView item (i.e - any Category) i would like to show items those belongs to that particular Category only in ViewPa

Solution 1:

Your itemArrayList is global and on parsing you're adding items to that list each time you read a category. For that reason your itemListArray include all items. Since it is reference to a list when you add an item to list, you're also adding item to previous categories since they reference to same list. Try changing your inner loop like this.

ArrayList<Items> itemsArrayList = new ArrayList<Items>();    
for(int j=0; j<imagesArray.length(); j++)
                        {
                        JSONObject imagesObject = imagesArray.getJSONObject(j);

                    items = new Items();
                    items.setTitle(imagesObject.getString("title"));
                    items.setImage(imagesObject.getString("image"));                                

                    itemsArrayList.add(items);
                }

Post a Comment for "How To Pass Json Array Using Json Object"