gpt4 book ai didi

Android如何将对象用户传递给 Activity fragment

转载 作者:行者123 更新时间:2023-11-29 01:38:41 27 4
gpt4 key购买 nike

Intent mIntent = new Intent(Login.this, PlatformActivity.class);
Bundle bundle = new Bundle();
bundle.putSerializable("user",user);
mIntent.putExtras(bundle);
startActivity(mIntent);

public class User implements Serializable {

private List<UserAccount> userAccountList;
...
...
}

RuntimeException:Parcelable 遇到IOException 写入可序列化对象(name = com.orbis.mobile.User)

User 是不可序列化的,我想知道如何用 arrayList 传递 Object。如果用户没有设置userAccountList,它可以工作。

最佳答案

            ArrayList<UserAccount> userAccountList = user.getUserAccountList();
user.setUserAccountList(null);

bundle.putSerializable("user", user);

bundle.putSerializable("accountList", userAccountList);

mIntent.putExtras(bundle);
startActivity(mIntent);


user = (User) getIntent().getSerializableExtra("user");

ArrayList<UserAccount> accountNumberList = (ArrayList<UserAccount>) getIntent().getSerializableExtra("accountList");

user.setUserAccountList(accountNumberList);

关于Android如何将对象用户传递给 Activity fragment ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26245459/

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