更新时间:2022-11-18 19:49:43
您也许应该有你的对象实施的 Parcelable 。基本上,你必须添加的方法来写,从了解您的对象的成员包裹
,然后添加自定义的 CREATOR
,有一对夫妇的静态工厂方法内部类。有它的第一个链接页面上的演示,但它不是太难。
You should probably have your object implement Parcelable. Basically, you have to add methods to write and read the members of your object from a Parcel
, and then add custom CREATOR
inner class that has a couple of static factory methods. There's a demo of it on the first linked page, but it's not too hard.
然后,你可以保存在一个去与 Bundle.putParcelableArrayList()
。 (你必须投列表中,当你把它找回来用 Bundle.getParcelableArrayList()
但它会正常工作。)
Then you can just save the whole list in one go with Bundle.putParcelableArrayList()
. (You'll have to cast the list when you get it back out with Bundle.getParcelableArrayList()
but it will work fine.)