"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);

                     }

                });
}
复制代码
相关文章
|
5月前
|
缓存 Dart 开发工具
解决Flutter报错The method ‘File.create‘ has fewer named arguments than those of overridden method
解决Flutter报错The method ‘File.create‘ has fewer named arguments than those of overridden method
72 3
|
4月前
|
Docker 容器
ADD failed: file not found in build context or excluded by .dockerignore: stat irap_rule_center: fil
ADD failed: file not found in build context or excluded by .dockerignore: stat irap_rule_center: fil
|
5月前
|
网络安全
androidstudio无法启动,Failed to create a child event loop
androidstudio无法启动,Failed to create a child event loop
122 0
|
8月前
|
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
49 1
|
8月前
【echarts报错】: ‘normal‘ hierarchy in itemStyle has been removed since 4.0.
【echarts报错】: ‘normal‘ hierarchy in itemStyle has been removed since 4.0.
420 0
Unknown custom element: <add-employee> - did you register the component correctly? For red cursive c
原因: 1.组件名没写对(导入和注册不对应) 2.components少写了个s 3.组件命名最好是驼峰命名 4.导入时语法错误 5.代码中有两个components,后一个的值把前一个覆盖了 6.组件直接循环套用了
104 0
|
8月前
|
XML Android开发 数据格式
Error obtaining Ul hierarchy Reason: Error while obtaining Ul hierarchy XML file
Error obtaining Ul hierarchy Reason: Error while obtaining Ul hierarchy XML file
248 1
|
8月前
|
XML Android开发 数据格式
Error obtaining Ul hierarchy Reason_ Error while obtaining Ul hierarchy XML file
Error obtaining Ul hierarchy Reason_ Error while obtaining Ul hierarchy XML file
92 0
|
前端开发 JavaScript
[Bugfix]it looks like you called `mount()` without a global document being loade
jest测试react组件时尝试获取mount组件报错,并无法进行测试,解决过程记录。
101 1
loaded the "xxx" nib but the view outlet was not set 错误的解决办法。
loaded the "xxx" nib but the view outlet was not set 错误的解决办法。
233 0

热门文章

最新文章