将活动A中的mutableList传递给Kotlin中的活动B. [英] Pass a mutableList from activity A to activity B in Kotlin.
问题描述
我正在尝试通过Kotlin中的意图将数据从活动 A 传递到活动 B .
I'm trying to pass data from activity A to activity B through intent in Kotlin.
问题是我有一个videos: MutableList<Video>
,而intent.putParcelableArrayListExtra("VIDEOS", videos)
仅接受ArrayList<out Parcelable>
作为参数.
The problem is I have a videos: MutableList<Video>
and the intent.putParcelableArrayListExtra("VIDEOS", videos)
only accepts ArrayList<out Parcelable>
as arguments.
问题
*.如何从活动 A 向活动 B 发送可变表数据?
*. How do I send a mutableList data from activity A to activity B?
*.还是我必须将其转换为ArrayList<Video>
?
*. Or Do I have to convert it to ArrayList<Video>
?
PS: Video
实现可打包
推荐答案
将其转换为ArrayList
(或将其存储为第一个位置?)是一种简单的解决方案,如果您想坚持将其通过意图.有一个 ArrayList
构造函数,它以集合为参数:
Converting it to an ArrayList
(or storing it as one in the first place?) is the easy solution if you want to stick to passing it through an Intent. There's an ArrayList
constructor that takes a collection as its parameter:
intent.putParcelableArrayListExtra("VIDEOS", ArrayList(videos))
这篇关于将活动A中的mutableList传递给Kotlin中的活动B.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!