PHP
·
发表于 5年以前
·
阅读量:8073
data class UserBean(
var name: String,
var age: Int
) : Parcelable {
constructor(source: Parcel) : this(source.readString(), source.readInt())
override fun describeContents() = 0
override fun writeToParcel(dest: Parcel?, flags: Int) {
dest?.writeString(name)
dest?.writeInt(age)
}
companion object {
@JvmField val CREATOR: Parcelable.Creator<UserBean> = object : Parcelable.Creator<UserBean> {
override fun createFromParcel(source: Parcel): UserBean = UserBean(source)
override fun newArray(size: Int): Array<UserBean?> = arrayOfNulls(size)
}
}
}