通常每个Activity对应1个Layout,在onCreate时指定layout(否则引用的还是main的layout),然后调用startActivity:
protected override void OnCreate (Bundle bundle) { SetContentView (Resource.Layout.UserRegister); base.OnCreate (bundle); // Create your application here var btnBack = FindViewById<Button> (Resource.Id.btnUserRgst_Back); btnBack.Click += (object sender, EventArgs e) => { StartActivity(typeof(MainActivity)); }; }
如果要传值,可以使用intent:
var intent = new Intent(this, typeof(UserRegister)); StartActivity(intent);
以上就是C# 使用Xamarin 开发应用 -- 切换Activity 的内容,更多相关内容请关注PHP中文网(m.sbmmt.com)!