Android Studio使用Parcelable序列化插件

Android Studio使用Parcelable序列化插件

android studio中planturl如何使用_对象

android studio中planturl如何使用_Android Studio_02

android studio中planturl如何使用_Android Studio_03

android studio中planturl如何使用_Parcelable_04

android studio中planturl如何使用_插件_05

import android.os.Parcel;
import android.os.Parcelable;
public class Ball implements Parcelable {
private int width;
private int height;
public int getWidth() {
return width;
}
public void setWidth(int width) {
this.width = width;
}
public int getHeight() {
return height;
}
public void setHeight(int height) {
this.height = height;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(this.width);
dest.writeInt(this.height);
}
public Ball() {
}
protected Ball(Parcel in) {
this.width = in.readInt();
this.height = in.readInt();
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
@Override
public Ball createFromParcel(Parcel source) {
return new Ball(source);
}
@Override
public Ball[] newArray(int size) {
return new Ball[size];
}
};
}

参考:

Android Studio使用Parcelable序列化插件相关教程