在ActivityA跳转到ActivityB后。activityB返回到ActivityA并带参数返回
首先再activitya中跳转到b
var intent = new Intent(this, typeof(PurchaseDtlActivity));
intent.PutExtra("sku", data[position].Title);
intent.PutExtra("s", data[position].Pv);
StartActivityForResult(intent, 2);
b返回数据并关闭
Intent resultIntent = new Intent();
Bundle bundle = new Bundle();
bundle.PutString("Sku",sku );
bundle.PutInt("Qty", Convert.ToInt32(textView2.Text));
resultIntent.PutExtras(bundle);
this.SetResult(Result.Ok,resultIntent);
this.Finish();
在a中重写OnActivityResult方法以便接受
protected override void OnActivityResult(int requestCode, Result resultVal, Intent datas)
{
//如果是ok那么就修改一下数量
if (requestCode==2&&resultVal== Result.Ok)
{
string sku = datas.GetStringExtra("Sku");
int qty = datas.GetIntExtra("Qty",1);
foreach (var item in data)
{
if (item.Title==sku)
{
item.Pv = qty;
PurchaseActivity.shua();
return;
}
}
}
}
大家如果有问题可以 Console.WriteLine(”加群“+"537905238"); |