【发布时间】:2015-10-26 21:03:50
【问题描述】:
我尝试在活动之间传递数据并出现错误:
C:\Users\nemesis\Documents\GitHub\Murakami_kiev\MurakamiKiev\Menu Activities\SoupesActivity.cs(5,5): 错误 CS0121: The call is ambiguous between the following methods or properties: 'Android.Content.Intent .PutExtra(string, short)' 和 'Android.Content.Intent.PutExtra(string, bool)' (CS0121) (MurakamiKiev)
活动 1 中的代码:
private void ParseAndDisplay1(JsonValue json) {
TextView productname = FindViewById<TextView> (Resource.Id.posttittle);
TextView price = FindViewById<TextView> (Resource.Id.price);
TextView weight = FindViewById<TextView> (Resource.Id.weight);
productname.Click += delegate {
var intent404 = new Intent (this, typeof(SoupesDetailActivity1));
JsonValue firstitem = json [81];
intent404.PutExtra ("title", firstitem ["post_title"]);
intent404.PutExtra ("price", firstitem ["price"] + " грн");
intent404.PutExtra ("weight", firstitem ["weight"] + "г");
StartActivity (intent404);
};
}
接收属性时 Activity2 中的代码:
private void ParseAndDisplay(JsonValue json) {
TextView productname = FindViewById<TextView>(Resource.Id.posttitle);
TextView content = FindViewById<TextView>(Resource.Id.postcontent);
TextView price = FindViewById<TextView>(Resource.Id.price);
TextView weight = FindViewById<TextView>(Resource.Id.weight);
//JsonValue firstitem = json[81];
productname.Text = Intent.GetStringExtra("title");
content.Text = firstitem["post_excerpt"];
price.Text = firstitem["price"] + " грн";
weight.Text = firstitem["weight"] + "г";
}
代码有什么问题?
谢谢你的帮助
【问题讨论】: