


There are several ways to implement an event handler but C# has one of the coolest (using a Lambda expression):īy the way, if you are interested in the code I used to make this post, check it on GitHub or download it here: tl dr In the C# version you can see the Activity decorator, which tells the name of the activity ( Label), wether it is the app launcher( MainLauncher) and the icon ( Icon), these stuff goes in the Android Manifest in the traditional approach.įor UI elements such as Buttons, TextViews and EditTexts are equally named and declared:īy convention, in C# methods must start with an uppercase letter, and the override indicator is not an annotation but a keyword, this is the OnCreate method:Īnother interesting thing is the automatically generated R or Resource class, when using Xamarin this class is named Resoruce, and we can use it to find views:Īs you can see, the diamond syntax provides a way to return the view without casting the view ourselves. In Xamarin.Android our classes related to the UI have to derive from Activity as in traditional Android, here is the class declaration: This worked too for string resources named String.xml and string.xml. Layout files are the same in both approaches, in fact, I copied the content of Main.axml (Xamarin) to layout_main.xmland the result was the same.

In Android Studio the class MainActivity.java is in the package whereas in Xamarin Studio the class `MainActivity.cs` is directly in the Solution's root. As you might know in Java exist the concept of Packages, and it is strongly asociated to the underlying folder structure.
