通常,如果我想开始一项新活动,我可以使用
StartActivity(typeof(foo));
这可以。
我也可以设置一个意图
Intent i = new Intent(this, typeof(foo));
StartActivity(i);
问题是这样的。我有 Activity A。这会触发 Activity B。但是,我需要在使用 PutExtra 后触发 Activity B。如果我做
Intent i = new Intent(this, typeof(ActivityB));
当我在 Activity 中定义一个新的 Intent 时,monodroid 会很恼火。
有没有办法做到这一点
(伪代码)
[Activity]
public partial class A
{
protected override void OnCreate(Bundle savedInstance)
{
SetContentView(Resource.Layout.layout);
Button btnClick = FindViewById<Button>(Resource.Id.btnClicky);
btnClick.Click += new EventHandler(button_click);
}
private void button_Click(object s, EventArgs e)
{
Intent i = new Intent(this, typeof(B)); // <- gets annoyed
i.PutExtra("foo", 1);
i.PutExtra("bar", true);
StartActivity(i);
}
}
这里的任何帮助将不胜感激。
PFJ