• Android.Util.AndroidRuntimeException: Exception of type 'Android.Util.AndroidRuntimeException' was thrown. 异常


    android 的UI更新 非主线程内引发的异常。

    Android.Util.AndroidRuntimeException: Exception of type 'Android.Util.AndroidRuntimeException' was thrown.

    解决办法:

    public class ThreadDemo : Activity
    {
        TextView textview;
    
        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);
    
            // Create a new TextView and set it as our view
            textview = new TextView (this);
            textview.Text = "Working..";
    
            SetContentView (textview);
    
            ThreadPool.QueueUserWorkItem (o => SlowMethod ());
        }
    
        private void SlowMethod ()
        {
            Thread.Sleep (5000);
            RunOnUiThread (() => textview.Text = "Method Complete");
        }
    }

    参考:http://docs.xamarin.com/guides/android/advanced_topics/writing_responsive_applications

  • 相关阅读:
    计算机系统概述
    Qt学习--初学注意事项
    Qt实现一个简单的TextEditor
    Qt 用户登录界面
    C++ 模板
    多态与虚函数
    继承与派生
    C++ 运算符重载
    web安全-点击劫持
    web安全问题-cookie
  • 原文地址:https://www.cnblogs.com/ArRan/p/3033428.html
Copyright © 2020-2023  润新知