通常每個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中文網(www.php.cn)!