我做了什么:
上课
package com.powerpoint45.maze;
导入android.os.Parcel;导入android.os.Parcelable;
公共类 SerializableCustomData 实现 Parcelable{
public int[][] ints;
public int[][] getints() {
return ints;
}
public void setints(int[][] ints) {
this.ints = ints;
}
public SerializableCustomData() {
ints = new int[1][1];
}
public SerializableCustomData(Parcel in) {
ints = (int[][]) in.readSerializable();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeSerializable(ints);
}
public static final Parcelable.Creator<SerializableCustomData> CREATOR = new Parcelable.Creator<SerializableCustomData>() {
@Override
public SerializableCustomData createFromParcel(Parcel in) {
return new SerializableCustomData(in);
}
@Override
public SerializableCustomData[] newArray(int size) {
return new SerializableCustomData[size];
}
};
}
设置它并通过它
SerializableCustomData myParcelable = new SerializableCustomData();
myParcelable.setints(LevelCreator.LCLevelData);
Intent i = new Intent(LevelCreatorPopout.this, GameView.class);
i.putExtra("parcel",myParcelable);
startActivity(i);
抓住它
SerializableCustomData myParcelable = extras.getParcelable("parcel");
LevelData = myParcelable.getints();