I know downcasting isn't allowed in Java but is there a way to cast an array list of parcelable objects into an array list of cholesterolMonitors which implements parcelable?
In one of my abstract classes I have:
private ArrayList<Parcelable> objectList;
public ArrayList<Parcelable> getList() {
return objectList;
}
Then a concrete class which extends from this class has:
private ArrayList<CholesterolMonitor> monitor_list;
monitor_list=getList();//Retuns error here because for incompatible types
My cholesterol monitor class is:
public static final Creator<CholesterolMonitor> CREATOR = new
Creator<CholesterolMonitor>() {
@Override
public CholesterolMonitor createFromParcel(Parcel in) {
return new CholesterolMonitor(in);
}
@Override
public CholesterolMonitor[] newArray(int size) {
return new CholesterolMonitor[size];
}
};
@Override
public void writeToParcel(Parcel dest, int flags) {
}