传递ArrayList的使用对象为新的活动? [英] Passing ArrayList with objects to new Activity?

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

问题描述

我想从我的第一个活动传递一个ArrayList到下一个。基本上,第一个活动解析XML文件,并创建了内部对象的ArrayList。我想要做的就是发送的ArrayList我的第二个活动,并表现出一定的对象数据的一个ListView。

I'm trying to pass an ArrayList from my first Activity to the next one. Basically, the first activity parses an XML file and creates an ArrayList with objects inside. What I want to do is send that ArrayList to my second activity and show some of the object data in a ListView.

我想,意图这样做的,但它看起来像只有基本数据类型是通过意图通常通过。这是正确的?

I thought of doing this with an intent, but it looks like only primitive datatypes are usually passed through intents. Is this right?

如果是这样,这将是一个更好的解决方案来传递数据?当然,Android的必须提供的东西可以做这样的事情。

If so, what would be a better solution to pass the data? Certainly Android must provide something to be able to do this kind of thing.

任何帮助/ code的例子是真正的AP preciated ..

Any help/code examples are really appreciated..

感谢

编辑:

我解决了这个首先创建和调用的意图,并且只在解析我叫活动的XML。这样,我也没必要再传递的对象。但是,对于那些有兴趣,你可以了解如何通过活动,<一个传递数据href="http://developer.android.com/resources/faq/framework.html#3">here.

推荐答案

复杂类型可以通过Parcelable的方式通过。一个例子是在这样的问题:

Complex types may be passed by means of Parcelable. An example is in this question:

<一个href="http://stackoverflow.com/questions/5819238/help-with-passing-arraylist-and-parcelable-activity">Help与通过ArrayList和parcelable活动

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

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