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++;
        }
    }
}
 
程序员喜欢的方式,纯代码方式。

相关文章:

  • 2021-09-07
  • 2021-12-08
  • 2022-12-23
  • 2021-10-07
  • 2021-06-29
  • 2021-11-02
  • 2022-12-23
  • 2021-07-20
猜你喜欢
  • 2021-04-29
  • 2022-12-23
  • 2021-07-30
  • 2021-08-20
  • 2022-12-23
  • 2021-04-27
  • 2022-01-11
相关资源
相似解决方案