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)
用户不可序列化,我想知道如何使用arrayList传递Object。如果用户没有设置userAccountList,则可以使用它。
答案 0 :(得分:1)
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);
答案 1 :(得分:0)
List
不是Serializable
界面,您需要使用ArrayList
等实现
请参阅 http://docs.oracle.com/javase/7/docs/api/java/util/List.html
和 http://docs.oracle.com/javase/7/docs/api/java/util/ArrayList.html
public class User implements Serializable {
private ArrayList<UserAccount> userAccountList;
...
...
}
同样UserAccount
需要implements Serializable