[英]Passing arraylist in intent from one activity to another
I have a class 'Product' and i need to pass the arraylist of 'Product' objects from one activity to another. 我有一个“产品”类,我需要将“产品”对象的数组列表从一个活动传递到另一个活动。 I read that i can do so by making my Product class as Parcelable and use : putParcelableArrayListExtra (String name, ArrayList value).
我读到我可以通过将我的Product类设置为Parcelable并使用:putParcelableArrayListExtra(字符串名称,ArrayList值)来做到这一点。
In my app, i need to pass arraylists of objects from one activity to another. 在我的应用程序中,我需要将对象的数组列表从一个活动传递到另一个活动。 In this case, i need to make all those classes as parcelable and implement the interface methods.
在这种情况下,我需要将所有这些类设置为可打包的并实现接口方法。 Is this the correct way to solve the problem?
这是解决问题的正确方法吗? Is there any other way to send the list of objects in intents?
还有其他方法可以发送意图中的对象列表吗?
Thanks.. 谢谢..
是的,正确的方法是使用Parcelable
或对可以放入Intent的附加对象的另一种原始对象进行序列化
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.