How it works...

In steps 1 to 10, we created a blank solution and gave it a proper name. In step 10, we added an Android App project to that solution. The Android App project is a default template created by Visual Studio for Mac. It's a working prototype application for testing that everything is intact.

If you look at the Solution Explorer and click on the MainActivity.cs file, you will see all the action. Inside the OnCreate() method, the code looks like this:

base.OnCreate(savedInstanceState);

// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);

// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.myButton);

button.Click += delegate { button.Text = $"{count++} clicks!"; };

You can see a simple button. When you click on the button, its increments are counted and it updates the button label. FindViewById will locate the button and create a Button class. Finally, the button.Click event triggers the process of counting and storing it in the button caption.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.5.68