Parcelable

parcelable:

public static final Creator CREATOR = new Creator() {
        @Override
        public ImageBean createFromParcel(Parcel source) {
            ImageBean bean = new ImageBean();
            bean.path = source.readString();
            //1: true  0:false
            bean.isSelect = source.readByte() != 0;
            //子activity返回的对象,如果空返回空.读取数据的对象结果
            return bean;
        }

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

父activity

//bundle n:束,捆 从intent中得到数据
                    Bundle bundle = data.getExtras();
                    //从bundle中具体化需要的数据
                    ArrayList<ImageBean> imageBeen = bundle.getParcelableArrayList("selectImages");

子activity

 Intent intent = new Intent();
                //intent中放入数据
                intent.putParcelableArrayListExtra("selectImages", mSelectImages);
                //设置结果
                setResult(Activity.RESULT_OK, intent);
                finish();

你可能感兴趣的:(Parcelable)