id | title | brief | article | sdk | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
B05B5D58-E25F-A234-45BF-BB9BF3604AC8 |
Start an Activity |
This recipe shows how to start an activity defined within an application. |
|
|
To start an Activity, follow these steps.
- Create a new Xamarin.Android application. The project template will create a single activity named
MainActivity
(MainActivity.cs), which contains a button. - Add a second activity class named
Activity2
to the project. This class must inherit fromAndroid.App.Activity
- From the
button.Click
handler in MainActivity.cs, callStartActivity
, passing the type of the activity to start,Activity2
in this case.
button.Click += delegate {
StartActivity(typeof(Activity2));
};
Each screen in an application is represented by an activity. For more information on activities see the Getting Started series and the Activity Lifecycle in the Xamarin.Android documentation.