Issue
I'm using Parcelable
class to send Object
from one activity to another activity in Android Java.
Parcelable only implements for me String
data.
How I can read and write productsArrayList
and status
from this class?
public class Bill implements Parcelable {
private String id;
private Date createAt;
private ArrayList<Products> productsArrayList;
private ArrayList<StatusBill> status;
public Bill(String id, Date createAt, ArrayList<Products> productsArrayList, ArrayList<StatusBill> status) {
this.id = id;
this.createAt = createAt;
this.productsArrayList = productsArrayList;
this.status = status;
}
protected Bill(Parcel in) {
id = in.readString();
createAt = new Date(in.readLong());
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(id);
dest.writeLong(createAt.getTime());
}
public static final Creator<Bill> CREATOR = new Creator<Bill>() {
@Override
public Bill createFromParcel(Parcel in) {
return new Bill(in);
}
@Override
public Bill[] newArray(int size) {
return new Bill[size];
}
};
}
Solution
I find a solution for all case when using Parcelable
class
This website helps you to implement a Custom
class to Parcelable
class
Paste your Custom
class in textarea and click Build
button.
You will receive your Custom
class implemnets Parcelable
class
Answered By - LeeHari
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.