我创建了一个用户类并像这样初始化它:
User MyUser = new User("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
然后我用用户数据填充对象并将其传递给另一个活动,我这样做是这样的:
Intent intent = new Intent(this, typeof(MyActivity));
Bundle bundlee = new Bundle();
bundlee.PutParcelable("MyUser", MyUser); // Persist user class to next activity
intent.PutExtra("TheBundle", bundlee);
StartActivity(intent);
然后我在其他活动中检索用户数据,如下所示:
// I initialize a variable again
User MyUser = new User("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "");
MyUser = bundlee.GetParcelable("MyUser") as User;
我得到了除地址、城市和州之外的所有数据。很奇怪......我在代码中放置了断点,当我把它放在包中时,它就在那里,但是当我把它拿出来时,这三个字段是空字符串。
Helenr
相关分类