第一课 Hello

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Util;
 
namespace MyLesson
{
    [Activity(Label = "Lesson1", MainLauncher = true, Icon = "@drawable/icon")]
    public class Lesson1 : Activity
    {
        int count = 1;
        TextView tv;
 
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            LinearLayout layout = new LinearLayout(this);
            layout.Orientation = Orientation.Vertical;
            tv = new TextView(this);
            tv.Text = "Hello";
            Button b = new Button(this);
            b.Text = "Click me";
            b.Click += b_Click;
 
            layout.AddView(tv);
            layout.AddView(b);
            SetContentView(layout);
        }
 
        void b_Click(object sender, EventArgs e)
        {
            tv.Text = "Click times:" + count;
            count++;
        }
    }
}
 
程序员喜欢的方式,纯代码方式。

你可能感兴趣的:(EL)