seclooki.blogg.se

Xamarin studio android
Xamarin studio android




  1. XAMARIN STUDIO ANDROID CODE
  2. XAMARIN STUDIO ANDROID WINDOWS
Var textView = this.FindViewById(Resource.Id.HelloWorldText)

FindViewById takes identifier from the resource file as the parameter and returns the control. Next get the TextView identifier from the axml file. In our example we have a page called Main, so we are referring the file by So whenever an axml file is added or a control is added in the axml file immediately build your project. Initially I have said Resource class contains all the files and identifies used in the application. SetContentView is the method that takes the axml file as an input parameter and displays the file to the user.

xamarin studio android xamarin studio android

This method starts executing when the application starts running. This class contains an OnCreate method which is override from the base class Activity. Now let’s come back to the class MainActivity.cs. Let’s create a TextView control inside the LinearLayout (linear layout is a layout that arranges its children in a single column or a single row), assign it with an id “ HelloWorldText” and set the height, width and size property for the control.

  • Icon property specifies the icon for the Application.īefore we look in to the class deeper, let’s create a simple control in the Main.axml file, this file contains xml markups for android.
  • MainLauncher property specifies whether the current activity will be used as the Main Activity for the application, it is like the First page to be executed in the application.
  • Label property specified the name of the application and here the applications is called as ANDROID_APP.
  • The MainActivity class contains an Attribute called Activity and has properties called Label, MainLauncher and Icon.

    XAMARIN STUDIO ANDROID CODE

    When u open the MainActivity.cs file you will find the following code

    XAMARIN STUDIO ANDROID WINDOWS

    MainActivity.cs is nothing but a Page in windows world, so whenever you come across a file called activity then just remember it is a Page.

    xamarin studio android

    Where HelloWorldText is the id that is assigned to my TextView in my Main.axml file, which is explained below. So whenever a developer wants to access a control through its id he has to use like the following Resource folder contains all the resources we create in the application like icons, axml files and importantly all the id’s (identifiers) that we assign to a controls in the axml page.






    Xamarin studio android