1.Activity 之间传递ArrayList
public class MediaItem implements Serializable{
//注意实现 Seralizable
否则:报 Parcel: unable to marshal value错误
private String Name;//名称
private long duration;//时长
private long size;//大小
private String artist;//演唱者
private String data;//地址
public void setName(String name) {
Name = name;
}
public void setDuration(long duration) {
this.duration = duration;
}
......
2. ArrayList<MediaItem >
private ArrayList<MediaItem> mediaItems;
Intent intent = new Intent(context,SystemVideoPlayer.class); Bundle bundle = new Bundle(); bundle.putSerializable("videolist",mediaItems); MediaItem mediaItem1= mediaItems.get(i); //bundle.putSerializable("videolist",mediaItem1); intent.putExtras(bundle); intent.putExtra("position",i); context.startActivity(intent);
第二个Activity:getData()
mediaItems = (ArrayList<MediaItem>) getIntent().getSerializableExtra("videolist"); position = getIntent().getIntExtra("position",0);