Home >Backend Development >C#.Net Tutorial >C# uses Xamarin to develop applications -- switching activities

C# uses Xamarin to develop applications -- switching activities

黄舟
黄舟Original
2017-03-01 10:38:432159browse

Usually each Activity corresponds to 1 Layout. Specify the layout during onCreate (otherwise it still refers to the main layout), and then call 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));
			};
		}

If you want to pass Value, you can use intent:

var intent = new Intent(this, typeof(UserRegister));
				StartActivity(intent);

The above is the content of C# using Xamarin to develop applications--switching Activity. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn