如何将在意图列表 [英] How to put a List in intent

查看:85
本文介绍了如何将在意图列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的活动之一列表,需要将它传递到下一个活动。

I have a List in one of my activities and need to pass it to the next activity.

private List<Item> selectedData;  

我试图把这个在意图:

I tried putting this in intent by :

intent.putExtra("selectedData", selectedData);  

但它不工作。有什么可以做?

But it is not working. What can be done?

推荐答案

您必须先实例化列表来具体类型。 列表本身就是一个接口。

You have to instantiate the List to a concrete type first. List itself is an interface.

如果您implement在对象中的 Parcelable 接口那么你可以使用<一个href="http://developer.android.com/reference/android/content/Intent.html#putParcelableArrayListExtra%28java.lang.String,%20java.util.ArrayList%3C?%20extends%20android.os.Parcelable%3E%29"><$c$c>putParcelableArrayListExtra()方法将其添加到意图

这篇关于如何将在意图列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆