C# 使用Xamarin 开发应用 -- 切换Activity

来源:互联网 发布:油田网络宽带客服电话 编辑:程序博客网 时间:2024/06/07 04:23
通常每个Activity对应1个Layout,在onCreate时指定layout(否则引用的还是main的layout),然后调用startActivity:
protected override void OnCreate (Bundle bundle){SetContentView (Resource.Layout.UserRegister);base.OnCreate (bundle);// Create your application herevar 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);


1 0
原创粉丝点击