gpt4 book ai didi

java - 如何在android中使用intent传递数组列表

转载 作者:搜寻专家 更新时间:2023-11-01 09:47:25 24 4
gpt4 key购买 nike

How can i pass array list from one activity to another activity using intent.

来自 Activity

 ArrayList<ServicesInfo> bookedService = new ArrayList<ServicesInfo>();`
Intent intent = new Intent(getActivity() , Proceedtocart.class);
intent.putExtra("Listview",bookedService);
startActivity(intent);

到 Activity

 bookedService = (ArrayList<BookedInfo>) getIntent().getSerializableExtra("Listview");

while running am getting error as "java.lang.runtimeexception parcel unable to marshal value android"

Help to to fix this issue

最佳答案

试试这个:

Intent intent = new Intent(this, NextActivity.class);
intent.putStringArrayListExtra("Listview", bookedService);
startActivity(intent);

在 NextActivity 上:

yourArrayList = getIntent().getStringArrayListExtra("Listview");

关于java - 如何在android中使用intent传递数组列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37359182/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com