【发布时间】:2015-11-20 11:40:18
【问题描述】:
我有产品列表的活动,我将属性传递给购物篮活动
产品列表活动中的代码:
zakazat.Click += delegate
{
var intent = new Intent(this, typeof(CartActivity));
intent.PutExtra ("title", (string)(firstitem ["post_title"]));
intent.PutExtra ("price", (string)(firstitem ["price"] + " грн"));
intent.PutExtra ("weight", (string)(firstitem ["weight"] + "г"));
StartActivity(intent);
在购物篮中接收产品:
public void Display (){
LinearLayout display = FindViewById<LinearLayout> (Resource.Id.product1);
TextView productname = FindViewById<TextView> (Resource.Id.posttittle1);
TextView price = FindViewById<TextView> (Resource.Id.price1);
TextView weight = FindViewById<TextView> (Resource.Id.weight1);
price.Text = Intent.GetStringExtra("price");
productname.Text = Intent.GetStringExtra("title");
if (productname.Text == Intent.GetStringExtra ("title")) {
display.Visibility = ViewStates.Visible;
}
else {
display.Visibility = ViewStates.Gone;
}
weight.Text = Intent.GetStringExtra("weight");
}
我有两个问题,当我改变活动时如何保存这个属性以及如何在后台传递这个属性?
有什么建议可以让我实现这一点吗?
【问题讨论】:
-
不。我意识到转移到另一个活动。正如我在@ZahanSafallwa 帖子末尾所写的那样,我需要在活动中保存属性
-
保存属性是什么意思?将数据存储到文件之类的东西???
-
切换活动时保存属性,再次打开时看到。 @ZahanSafallwa