//从包裹中读取时,它给我的错误是无法在数组列表中转换void。
Source Code:
public class GetTripsByUserIdModel implements Parcelable{
private static final long serialVersionUID = 1L;
private String success;
private String tripId;
private String tripRequestedBy;
private String [] tripRequestedTo;
private String tripAcceptedById;
private String tripAcceptedByName;
private String tripConductedBy;
private String tripStatus;
private String tripCreatedOn;
private String tripScheduledBeginOn;
private String tripScheduledEndOn;
private String tripStartOn;
private String tripCompleteOn;
private String tripNotes;
private ArrayList<TripDetailModel> tripDetails;
private boolean mIsSeparator;
public GetTripsByUserIdModel() {
// TODO Auto-generated constructor stub
}
public GetTripsByUserIdModel(String tripId, String tripRequestedBy,String tripAcceptedById,String tripAcceptedByName,String tripConductedBy
,String tripStatus,String tripCreatedOn,String tripScheduledBeginOn,String tripScheduledEndOn,
String tripStartOn,String tripCompleteOn,String tripNotes,ArrayList<TripDetailModel> tripDetails,boolean mIsSeparator){
this.tripId = tripId;
this.tripRequestedBy = tripRequestedBy;
this.tripAcceptedById = tripAcceptedById;
this.tripAcceptedByName = tripAcceptedByName;
this.tripConductedBy = tripConductedBy;
this.tripStatus = tripStatus;
this.tripCreatedOn = tripCreatedOn;
this.tripScheduledBeginOn = tripScheduledBeginOn;
this.tripScheduledEndOn = tripScheduledEndOn;
this.tripStartOn = tripStartOn;
this.tripCompleteOn = tripCompleteOn;
this.tripNotes = tripNotes;
this.tripDetails = tripDetails;
this.mIsSeparator = mIsSeparator;
}
public GetTripsByUserIdModel(Parcel in) {
readFromParcel(in);
}
private void readFromParcel(Parcel in) {
this.success = in.readString();
this.tripId = in.readString();
this.tripRequestedBy = in.readString();
//this.tripRequestedTo = in.readStringArray(tripRequestedTo);
this.tripAcceptedById = in.readString();
this.tripAcceptedByName = in.readString();
this.tripConductedBy = in.readString();
this.tripStatus = in.readString();
this.tripCreatedOn = in.readString();
this.tripScheduledBeginOn = in.readString();
this.tripScheduledEndOn = in.readString();
this.tripStartOn = in.readString();
this.tripCompleteOn = in.readString();
this.tripNotes = in.readString();
this.tripDetails = new ArrayList<TripDetailModel>();
this.tripDetails = in.readTypedList(this.tripDetails, TripDetailModel.CREATOR);
}
}
//在阅读&#34; in.readTypedList&#34;在最后一行。它给出错误无法将void转换为ArrayList()。
//Please suggest any mistake i am doing.
请解决
答案 0 :(得分:1)
public final void readTypedList(List list,Creator c)。 readTypedList的返回类型为void。
http://developer.android.com/reference/android/os/Parcel.html#readTypedList(java.util.List,android.os.Parcelable.Creator)
private void readFromParcel(Parcel in) {
this.success = in.readString();
this.tripId = in.readString();
this.tripRequestedBy = in.readString();
//this.tripRequestedTo = in.readStringArray(tripRequestedTo);
this.tripAcceptedById = in.readString();
this.tripAcceptedByName = in.readString();
this.tripConductedBy = in.readString();
this.tripStatus = in.readString();
this.tripCreatedOn = in.readString();
this.tripScheduledBeginOn = in.readString();
this.tripScheduledEndOn = in.readString();
this.tripStartOn = in.readString();
this.tripCompleteOn = in.readString();
this.tripNotes = in.readString();
this.tripDetails = new ArrayList<TripDetailModel>();
/*this.tripDetails = in.readTypedList(this.tripDetails, TripDetailModel.CREATOR);*/
in.readTypedList(this.tripDetails, TripDetailModel.CREATOR);
}