添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public MyParcelable createFromParcel(Parcel in) { return new MyParcelable(in); public MyParcelable[] newArray(int size) { return new MyParcelable[size]; private MyParcelable(Parcel in) { mData = in.readInt(); Enter fullscreen mode Exit fullscreen mode

I’m not really a fan of this type of implementation because it will make my data class more difficult to read and confusing.

Typically it is complicated to pass a list of objects between Activities. But lately in Kotlin all you have to do is simple.

First, in your data class you implement Serializable.

@Entity
data class ItemCount(
    @ColumnInfo(name = "id") val itemID: Int,
    @ColumnInfo(name = "name") val name: String
): Serializable {
    @PrimaryKey(autoGenerate = true) var id: Int? = null
    Enter fullscreen mode
    Exit fullscreen mode
val intent = Intent(this, FinishScanActivity::class.java)
intent.putExtra("list", listItemCount as Serializable)
startActivity(intent)
    Enter fullscreen mode
    Exit fullscreen mode
      

Built on Forem — the open source software that powers DEV and other inclusive communities.

Made with love and Ruby on Rails. DEV Community © 2016 - 2024.