通过Bundle传递ArrayList对象? [英] Passing ArrayList Objects through Bundle?

查看:702
本文介绍了通过Bundle传递ArrayList对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

在Android中的活动之间传递非原始类型的数据

hi ...
在我的android中,我需要通过bundle将ArrayList对象从第一个活动传递给第二个活动,并在第二个活动中检索相同的对象。

hi... In my android i need to pass ArrayList object from first activity to a second activity through bundles and retrieve the same object in the second activity ...

请帮助我的代码...

pls help me with the code ...

谢谢:)

推荐答案

你看过Bundle的文档吗? Android - Bundle文档

Have you looked at the docs for Bundle? Android - Bundle docs

如果您的ArrayList包含简单的值,您可以在src活动中使用类似putIntArray的东西,并在dest活动中使用getIntArray。

If your ArrayList contains simple values, you can use something like putIntArray in the src activity and getIntArray in the dest activity.

否则,您的ArrayList对象将必须派生自Parcelable,您将使用put / getParcelableArray方法。

Otherwise your ArrayList objects will have to derive from Parcelable and you'll use the put/getParcelableArray methods accordingly.

这篇关于通过Bundle传递ArrayList对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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