Let's create a Layout using the Xamarin Studio designer:
Create a new Android Application solution named
LayoutDemo
.Add a new Android Layout file to the
/Resources/layouts
folder namedMainLayout
.When the designer opens, open the Toolbox pad.
From the Text Fields group, drag a Plain Text object onto your canvas.
From the Form Widgets group, drag a Button object onto your canvas.
Again from the Form Widgets group, drag a Text (Medium) label object onto you canvas.
Your layout should look something like the following screenshot:
Replace the
OnCreate()
method with the following code:protected override void OnCreate (Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.MainLayout); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button> (Resource.Id.button1); TextView textView = FindViewById<TextView> (Resource.Id.textView1...