zoukankan      html  css  js  c++  java
  • Activity调用静态方法改变UI,使用Handler来改变UI显示

    本人菜鸟,请各位多多指点,不足之处,请斧正.没啥技术含量,就权当丰富下mono for android的小代码.

    Activity调用静态方法改变UI

    using System;
    
    using Android.App;
    using Android.Content;
    using Android.Runtime;
    using Android.Views;
    using Android.Widget;
    using Android.OS;
    
    namespace AndroidApplication1
    {
        [Activity(Label = "AndroidApplication1", MainLauncher = true, Icon = "@drawable/icon")]
        public class Activity1 : 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 button from the layout resource,
                // and attach an event to it
                Button button = FindViewById<Button>(Resource.Id.MyButton);
    
                button.Click += delegate { Class1.fun("改变一下咯", button); };
            }
        }
    }

    使用Handler来改变UI显示

    using System;
    using System.Collections.Generic;
    using System.Text;
    using Android.App;
    using Android.OS;
    using Android.Widget;
    namespace AndroidApplication1
    {
        public static class Class1
        {
            public static void fun(string str, Button button)
            {
                Java.Lang.Runnable rb;
                Handler handler = new Handler();
                rb = new Java.Lang.Runnable(() =>
                {
                    button.Text = str;
                });
                handler.PostDelayed(rb, 1000);
            }
    
        }
    }

    代码不对,请告诉我哦.

  • 相关阅读:
    css中的元素旋转
    display:inlineblock的深入理解
    js时间获取。
    长英文自动换行的最终解决方法
    jqery图片展示效果
    链接A引发的思考
    电子邮件制作规范和建议
    overflow与textindent:9999px 字体隐藏及input value偏移
    jQuery load的详解
    转载:前端调试利器DebugBa
  • 原文地址:https://www.cnblogs.com/laxknight/p/3712918.html
Copyright © 2011-2022 走看看