{"id":1116,"date":"2022-02-19T02:47:16","date_gmt":"2022-02-19T02:47:16","guid":{"rendered":"https:\/\/clinicamaddarena.com.br\/?p=1116"},"modified":"2023-11-11T12:51:29","modified_gmt":"2023-11-11T12:51:29","slug":"deploying-and-running-your-first-c-net-xamarin","status":"publish","type":"post","link":"https:\/\/clinicamaddarena.com.br\/blog\/deploying-and-running-your-first-c-net-xamarin\/","title":{"rendered":"Deploying and Running Your First C# NET Xamarin Mobile App"},"content":{"rendered":"
In this section, we will modify our project and create a button which will display text upon click. After our textview that we created, we will add a button as shown below. Instead of adding the code for accessing the Web service to each project, I am going to create a new Class Library project. This class library will serve as the shared library to be used by both the iPhone and Android projects. On the solution, open Resources \u2192 layout \u2192 Main.axml file. Switch from Design View and go to the Source file and type the following lines of code to build your app.<\/p>\n
Just like in the iPhone project, you create an instance of the MyClass class and then proceed to call its USDtoEURRate() method. The only difference is that in Android, you use the RunOnUiThread() method to display the Toast window in the main UI thread. Run the application on the AVD and you can see the exchange rate after a while (see Figure 28). Expand the Resources item and then choose Layout and you can see the Main.axml file listed (see Figure 16). The Main.axml file contains the layout for your activity. In the editor, you can drag-and-drop widgets from the Toolbox onto the design surface.<\/p>\n
First, launch Xamarin Studio and you’ll see the opening screen, as shown in Figure 2. All the programs in this tutorial have been developed using Visual C#. Therefore, you should have a good understanding of code written in C# programming language. Tutorials Point is a leading https:\/\/wizardsdev.com\/en\/news\/new-mobile-course\/<\/a> Ed Tech company striving to provide the best learning material on technical and non-technical subjects. Open MainActivity.cs file and replace the existing code with the following lines of code. Enter the URL for the Web service and click the Jump to button (see Figure 25).<\/p>\n Instead, whatever statements added here are reflected in Xamarin Studio automatically. Be sure to save the .xib file in Xcode and then exit Xcode. In this chapter, we will see how to create a small Android application using Xamarin. In the MainActivity.cs file, add the statements that are new, as shown in Listing 7. You can compile the Class Library project into a DLL by selecting Build | Build WebServiceAccess. By this point, you should have a good feel for developing iOS and Android apps using Xamarin.<\/p>\n Also, ensure that the HelloiPhoneViewController.h file is selected (see Figure 7). Xamarin’s approach is to let developers create UI that are unique to each platform, and then create components that can be reused easily on another platform. Xamarin takes the middle path; it respects the uniqueness of each platform and does not force developers to create apps that look the same on all platforms. On the contrary, it encourages developers to take advantage of the features that each platform offers.<\/p>\n In a nutshell, Figure 1 shows how Xamarin works. You write your UI code for each specific platform-one for Android and one for an iOS device. Then write business logic that can be reused on both platforms. Fill in the rest of the fields and click the OK button. You can select it from the list of existing Android Virtual Devices and then click Start to launch it.<\/p>\n Click the Connect button to create an IBAction for the button. Click on the New button to create a new project. For now, expand the iOS section (see Figure 3) and select iPhone. On the right-side of the dialog box, select Single View Application. A good IDE enables acceleration of any development effort.<\/p>\n<\/p>\n
Integrated Development Environment (IDE): Xamarin Studio<\/h2>\n
<\/p>\n
Building Your First Mobile App with C# .NET and Xamarin<\/h2>\n