"Only the original thread that created a view hierarchy can touch its views.” 解决方法

简介:

这个主要总是,开启的线程和 UI 线程(主线程)不是同一个线程.可以Runnable方式避免,如下例所示就可以解决这个问题了。

复制代码
public static void updateText(Activity act, resID)
{

 loadingText = (TextView) activity.findViewById(R.id.loadingScreenTextView);
          act.runOnUiThread(new Runnable() 
                {
                     public void run() 
                     {
                       loadingText.setText(resID);

                     }

                });
}
复制代码
相关文章
|
6月前
|
Android开发
Can t process attribute android:fillColor=@color/camera_progress_delete: references to other resou
Can t process attribute android:fillColor=@color/camera_progress_delete: references to other resou
44 1
|
6月前
【echarts报错】: ‘normal‘ hierarchy in itemStyle has been removed since 4.0.
【echarts报错】: ‘normal‘ hierarchy in itemStyle has been removed since 4.0.
362 0
|
图形学 Windows
Unity报错之 No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager
Unity2019操作对图集进行操作编辑出错:No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager.
1237 0
Unity报错之 No Sprite Editor Window registered. Please download 2D Sprite package from Package Manager
|
Android开发
【错误记录】Android 文件查看错误 ( Error opening contents of device file ““: Cannot create directory )
【错误记录】Android 文件查看错误 ( Error opening contents of device file ““: Cannot create directory )
609 0
【错误记录】Android 文件查看错误 ( Error opening contents of device file ““: Cannot create directory )
App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW in
App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW in
122 0
loaded the "xxx" nib but the view outlet was not set 错误的解决办法。
loaded the "xxx" nib but the view outlet was not set 错误的解决办法。
221 0
|
Java
Preference跳转activity出错Unable to find explicit activity class
使用Preference可以非常方便的实现类似设置页面这样的菜单布局,甚至可以不需写java代码。那么可以在Preference中直接添加页面跳转么?其实非常简单,在Preference添加intent标签即可
526 0
|
Java
Could not find class 'android.support.v4.view.ViewPager', referenced from method***
Could not find class 'android.support.v4.view.ViewPager', referenced from method***
156 0
Could not find class 'android.support.v4.view.ViewPager', referenced from method***
|
Android开发
Only the original thread that created a view hierarchy can touch its views.
/********************************************************************************** * Only the original thread that created a view hierarchy can touch its views. * 说明: * 自定义view的时候出现这个错误,是用错了方法。
1102 0