android putParcelableArrayList putParcelable

import android.os.Parcel;
import android.os.Parcelable;

class VideoItem implements Parcelable {

long id;
String path;
String title;
String duration;
String folder;
String mimeType;
long size;

public VideoItem() {
// TODO Auto-generated constructor stub
}

public VideoItem(long id, String path, String title, String duration, String folder, String mimeType, long size) {
super();
this.id = id;
this.path = path;
this.title = title;
this.duration = duration;
this.folder = folder;
this.mimeType = mimeType;
this.size = size;
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getPath() {
return path;
}

public void setPath(String path) {
this.path = path;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getDuration() {
return duration;
}

public void setDuration(String duration) {
this.duration = duration;
}

public String getFolder() {
return folder;
}

public void setFolder(String folder) {
this.folder = folder;
}

public String getMimeType() {
return mimeType;
}

public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}

public long getSize() {
return size;
}

public void setSize(long size) {
this.size = size;
}

public static final Parcelable.Creator<VideoItem> CREATOR = new Creator<VideoItem>() {

@Override
public VideoItem[] newArray(int size) {
return new VideoItem[size];
}

@Override
public VideoItem createFromParcel(Parcel source) {
VideoItem item = new VideoItem();
item.id = source.readLong();
item.path = source.readString();
item.title = source.readString();
item.duration = source.readString();
item.folder = source.readString();
item.mimeType = source.readString();
item.size = source.readLong();
return item;
}
};

@Override
public int describeContents() {
return 0;
}

@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeLong(id);
dest.writeString(path);
dest.writeString(title);
dest.writeString(duration);
dest.writeString(folder);
dest.writeString(mimeType);
dest.writeLong(size);
}
}

Note: CREATOR must be a static method

-----------------------------sent----------------------------------
Intent intent = new Intent(A.this, B.class);
Bundle bundle = new Bundle();
bundle.putParcelableArrayList("videoitems", mFolderMap.get(mFolderList.get(position).folder));
intent.putExtras(bundle);
startActivity(intent);

---------------------------receive------------------------------
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
mBackTitle.setText(bundle.getString("title"));
mVideoItems = bundle.getParcelableArrayList("videoitems");
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值