初次体验monodroid

昨天,晚上终于等到了monodroid的官方下载权!终于可以告别java和eclipse,重新回归C#和vs的怀抱了!

安装的Visual Studio 2010 MonoDroid包括五个步骤:

  1. Java SDK的安装
  2. 安装Android SDK
  3. 配置你的模拟器
  4. 安装Visual Studio 2010中MonoDroid插件
  5. (可选) 配置Visual Studio中的MonoDroid为插件

 具体安装可以去官方网站上看看。

 

 新建一个monodroid的工程:

写一段测试代码:

using System;


using Android.App;

using Android.Content;

using Android.Runtime;

using Android.Views;

using Android.Widget;

using Android.OS;


namespace MonoDroidApplication1

{

    [Activity(Label = "My Activity", MainLauncher = true)]

    public class Activity1 : Activity

    {

        int count = 1;


        public Activity1(IntPtr handle)

            : base(handle)

        {

        }


        protected override void OnCreate(Bundle bundle)

        {

            base.OnCreate(bundle);


            // 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 = string.Format("{0} clicks!", count++); };

        }

    }

} 

 运行,运行需要在android的手机上安装monodroid框架

 

 运行helloworld,在android的上的效果

 

 

效果还不错吧! 

posted @ 2010-09-28 10:12  大肚小男人  阅读(7009)  评论(43编辑  收藏  举报