O'Reilly logo

Cross-platform UI Development with Xamarin.Forms by Paul F. Johnson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Instantiating Xamarin Forms within an app

We instantiate Xamarin Forms within each supported platform of the app. Xamarin Forms support the following platforms:

  • Android
  • iOS
  • Windows Phone

Android

Typically, an activity to start an activity class looks like this:

public class MyActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
         base.OnCreate(bundle);
         // then whatever you need to do

To start a Xamarin Forms app, this changes as we are not inheriting the Activity but a FormsApplicationActivity, or more precisely:

public class MyActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity { protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); LoadApplication(new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required