Android for VS (ii) Visual Studio Android Development instance

Source: Internet
Author: User

Android for VS (i) Visual Studio Android Development instance

Related vs Android development environment installation configuration You can see my previous post

Development and commissioning using VS2010 's own examples

First, the new project

FILE--New project, we chose the blank App (Android) project, such as

  

Second, the project directory structure

  

1) androidmanifest.xml

The project configuration profile, the project name, icon, and the permissions required to run the program can be declared here

2) Main.axml

interface layout and element definition files

3) MainActivity.cs

The code that corresponds to the Main.axml file handles the file with the following code:

Using system;using android.app;using android.content;using android.runtime;using android.views;using Android.Widget; Using Android.os;namespace app1{    [Activity (Label = "App1", Mainlauncher = true, Icon = "@drawable/icon")]    public Class mainactivity:activity    {        int count = 1;        protected override void OnCreate (bundle bundle)        {            base. OnCreate (bundle);            Set our view from the "main" layout resource            Setcontentview (Resource.Layout.Main);            Get our buttons from the layout resource,            //and attach a event to it            button button = findviewbyid<button& gt; (Resource.Id.MyButton);            button. Click + = delegate {button. Text = string. Format ("{0} clicks!", count++); };        }    }}

This code is the code for the original instance of VS2010, which implements the simple function of clicking Gay with a twist.

Third, compile option settings

Open the Project Properties page

  

The three options for application, Android Mainfest, Android option are present in the case of Xamarin installation and configuration success

Android Mainfest in Android SDK tools installation is normal, otherwise it will appear not in the range on the error page

1) compile using Android version

Set the compiled version of the project, generally using the lower version, the option of the version selection list comes from the Android installation list of the SDK

Through my test, if the direct download of Android version extracted to the platforms directory, in the VS this location is not read out. Need to use SDK Manager.exe for Android version update operation, the SDK Manager.exe update need to connect to Google Server, in the country is a wall, can be used to update the proxy server

2) Mininum and Taget

Minimum and target versions can use the compiled version of the settings

Four, start debugging

Add and select the emulator you use before starting debugging, and you can add and select the version you use from the Android emulator toolbar

  

After selecting the simulator version, you can press F5 to debug, and the version used for debugging must match the version of the compilation option. In the debug phase of the project directory will generate an APK file, this file and Eclipse debug generated files are not the same, eclipse generated files can be sent directly to the mobile phone installation use.

The files here are not allowed, to be published by the VS release operation, the release of an APK file can be placed on the phone to install

  

  

Android for VS (ii) Visual Studio Android Development instance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.