I'm having trouble with reading an ArrayList of Strings with a class that implements Parcelable.
I want to send 3 ArrayLists of Strings to a Fragment. Another thing I don't understand is how I'd use this class to actually send this data to a Fragment (I read somewhere else that you can use your own parcelable class to do this, but I don't know exactly how).
Here is the relevant code, I'll put comments in the places I think I need help.
package com.tsjd.HotMeals;
import java.util.ArrayList;
import android.os.Parcel;
import android.os.Parcelable;
public class RecipeListViewParcer implements Parcelable{
private ArrayList<String> titles;
private ArrayList<String> descriptions;
private ArrayList<String> images;
private RecipeListViewParcer(Parcel in) {
titles = in.readArrayList(String.class.getClassLoader()); //Need help here
descriptions = in.readArrayList(String.class.getClassLoader()); //Need help here
images = in.readArrayList(String.class.getClassLoader()); //Need help here
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel out, int flags) {
out.writeList(titles); //Need help here
out.writeList(descriptions); //Need help here
out.writeList(images); //Need help here
}
public static final Parcelable.Creator<RecipeListViewParcer> CREATOR
= new Parcelable.Creator<RecipeListViewParcer>() {
public RecipeListViewParcer createFromParcel(Parcel in) {
return new RecipeListViewParcer(in);
}
public RecipeListViewParcer[] newArray(int size) {
return new RecipeListViewParcer[size];
}
};
}