How I can parse Arraylist of JSON from one Fragment to another fragment here is my arraylist code where I am getting arraylist from my model:
private void setListOffers(JSONArray categoryArray) {
for (int i = 0; i < categoryArray.length(); i++) {
try {
JSONObject object = categoryArray.getJSONObject(i);
hotDealID = object.getInt("ID");
deals.add(new ListOffers(hotDealID));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
Here I am sending data from fraggment:
private ArrayList<ListOffers> deals = new ArrayList<>();
Fragment fragment = new HotDealFragment();
Bundle bundle = new Bundle();
bundle.putParcelableArrayList("dealsId", deals);
fragment.setArguments(bundle);
When I put this code then deals gives exception that wrong second argument and ListOffers
is my model where I am fetching data
and here is my model list Offers:
private int Id;
public ListOffers(int Id){
this.Id = Id;
}
public void setId(int id) {
Id = id;
}
public int getId() {
return Id;
}