如何在activites
之間通過ArrayList
類型ArrayList<ArrayList<CustomObject>>
?我已經執行與customObject
模型類。當我通過像intent.putParcelableArrayListExtra("catVideoList", categoriesVideoList)
它給出了錯誤。我知道如何通過ArrayList
像ArrayList<CustomObject>
。如何在活動之間傳遞ArrayList <ArrayList <customtype>>
下面是我的模型類:
public class VideoContentModel implements Parcelable {
String videoId;
String videoUrl;
String videoTitle;
String videoDescription;
String videoThumbnailUrl;
String videoDuration;
String videoBitrate;
String videoPublishDate;
String videoCreateDate;
String videoUpdateDate;
String videoChannelId;
String videoChannelName;
String videoFeedType;
public VideoContentModel(String videoId, String videoUrl, String videoTitle,
String videoThumbnailUrl, String videoDuration,
String videoBitrate, String videoPublishDate, String videoCreateDate,
String videoUpdateDate, String videoChannelId, String videoChannelName,
String videoFeedType, String videoDescription)
{
this.videoId = videoId;
this.videoUrl = videoUrl;
this.videoTitle = videoTitle;
this.videoThumbnailUrl = videoThumbnailUrl;
this.videoDuration = videoDuration;
this.videoBitrate = videoBitrate;
this.videoPublishDate = videoPublishDate;
this.videoCreateDate = videoCreateDate;
this.videoUpdateDate = videoUpdateDate;
this.videoChannelId = videoChannelId;
this.videoChannelName = videoChannelName;
this.videoFeedType = videoFeedType;
this.videoDescription = videoDescription;
}
public String getVideoId() {
return videoId;
}
public String getVideoUrl() {
return videoUrl;
}
public String getVideoTitle() {
return videoTitle;
}
public String getVideoDescription() {
return videoDescription;
}
public String getVideoThumbnailUrl() {
return videoThumbnailUrl;
}
public String getVideoDuration() {
return videoDuration;
}
public String getVideoBitrate() {
return videoBitrate;
}
public String getVideoPublishDate() {
return videoPublishDate;
}
public String getVideoCreateDate() {
return videoCreateDate;
}
public String getVideoUpdateDate() {
return videoUpdateDate;
}
public String getVideoChannelId() {
return videoChannelId;
}
public String getVideoChannelName() {
return videoChannelName;
}
public String getVideoFeedType() {
return videoFeedType;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.videoId);
dest.writeString(this.videoUrl);
dest.writeString(this.videoTitle);
dest.writeString(this.videoDescription);
dest.writeString(this.videoThumbnailUrl);
dest.writeString(this.videoDuration);
dest.writeString(this.videoBitrate);
dest.writeString(this.videoPublishDate);
dest.writeString(this.videoCreateDate);
dest.writeString(this.videoUpdateDate);
dest.writeString(this.videoChannelId);
dest.writeString(this.videoChannelName);
dest.writeString(this.videoFeedType);
}
protected VideoContentModel(Parcel in) {
this.videoId = in.readString();
this.videoUrl = in.readString();
this.videoTitle = in.readString();
this.videoDescription = in.readString();
this.videoThumbnailUrl = in.readString();
this.videoDuration = in.readString();
this.videoBitrate = in.readString();
this.videoPublishDate = in.readString();
this.videoCreateDate = in.readString();
this.videoUpdateDate = in.readString();
this.videoChannelId = in.readString();
this.videoChannelName = in.readString();
this.videoFeedType = in.readString();
}
public static final Parcelable.Creator<VideoContentModel> CREATOR = new Parcelable.Creator<VideoContentModel>() {
@Override
public VideoContentModel createFromParcel(Parcel source) {
return new VideoContentModel(source);
}
@Override
public VideoContentModel[] newArray(int size) {
return new VideoContentModel[size];
}
};
}
添加錯誤...... – Pavya
使用'putExtra'和'getParcelable'來在活動之間傳遞對象。 –
@Pravin下面的錯誤顯示類型Intent中的方法putParcelableArrayListExtra(String,ArrayList <?extends Parcelable>)不適用於參數(String,ArrayList>)' –