我怎么可以发送到列表中的Android Studio中另一项活动 [英] how can I send a List into another activity in Android Studio
问题描述
我知道,我可以通过将putextra()对我的意图添加一个字符串或整数,但我该怎么办,如果我要送一个列表? 例如,我的主要活动包含了一个名单,我有一个不同的活动,增加了一个项目到列表中,我有一个需要显示整个列表中的第三个活动
I know that I can add a string or an integer by putting putextra() on my Intent but what do I do if I have to send a List? For example, My main activity contains a list, I have a different activity that adds an item into the list and I have a third activity that needs to show the whole list
推荐答案
您的对象还可以实现Parcelable接口。然后你可以使用<一个href="http://developer.android.com/reference/android/os/Bundle.html#putParcelable(java.lang.String,%20android.os.Parcelable)"相对=nofollow> Bundle.putParcelable()
方法,并在意图传递活动之间的对象。
Your object can also implement Parcelable interface. Then you can use Bundle.putParcelable()
method and pass your object between activities within intent.
照片流应用程序使用此方法,并且可以用作参考的http: //$c$c.google.com/p/apps-for-android/
Photostream application uses this approach and may be used as a reference http://code.google.com/p/apps-for-android/
来源:谷歌Android的传递活动之间的对象:)
Source: google "pass objects between activities android" :)
这篇关于我怎么可以发送到列表中的Android Studio中另一项活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!