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

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

问题描述

可能的重复:
在活动之间传递非原始类型的数据在安卓中

你好...在我的 android 中,我需要通过包将 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 ...

请帮我写代码...

谢谢:)

推荐答案

您是否看过 Bundle 的文档?Android - 捆绑文档

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天全站免登陆