保存文本时,我关闭活动 [英] Save text when I close activity
本文介绍了保存文本时,我关闭活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写的Android应用程序在Xamarin并有篮子的活动。
I writing Android app in Xamarin and have basket activity.
我有篮子的活动时,我从产品列表中添加产品。
I have basket activity when I add products from list of products.
code添加属性
add.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);
};
code接收的属性。
Code of receiving attributes
productname.Text = Intent.GetStringExtra("title");
price.Text = Intent.GetStringExtra("price");
weight.Text = Intent.GetStringExtra("weight");
但是,当我回去,我所有的产品附加值删除。我怎么可以节省产品在篮子里,当我切换到另一个活动?
But when I go back, all my added products deleted. How I can save products in basket when i switch to another activity?
推荐答案
您可以覆盖将OnPause
。它被称为每次活动
/ 片段
走进后台。
You can override OnPause
. It is called every time the Activity
/ Fragment
went into background.
在code就应该是这样的:
In code it would look like this:
protected override void OnPause()
{
base.OnPause();
//Your code here
}
这篇关于保存文本时,我关闭活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文