这个主要总是,开启的线程和 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); } });
}

"Only the original thread that created a view hierarchy can touch its views.” 解决方法的更多相关文章

  1. Only the original thread that created a view hierarchy can touch its views解决办法

    这周操作系统作业布置了一个作业,内容是做个小软件,来模拟消费者生产者问题,作业实现起来不来,因为之前写过这个算法,所以关键步骤就是在消费和生产的时候更新缓存区的UI控件就行,之后问题就来了,出现了标题 ...

  2. Android: Only the original thread that created a view hierarchy can touch its views 异常

    最近自己再写一个小项目练手,创建一个线程从网络获取数据然后显示在 recyclerView 上.写好后发现页面能够显示,但是有时候会把请求的数据显示过来,有时候不会.点开 android monito ...

  3. 开发错误记录1:解决:Only the original thread that created a view hierarchy can touch its views.

    今天在项目中要使用圆角头像,导入开源 CircleImageView ,然后setImageBitmap()时 运行时就会发现,它会报一个致命性的异常:: · ERROR/AndroidRuntime ...

  4. Only the original thread that created a view hierarchy can touch its views

    在调试软件的时候出现如下的错误: 01-05 20:53:36.492: E/ZZShip(2043): android.view.ViewRootImpl$CalledFromWrongThread ...

  5. 浅析Android中的消息机制-解决:Only the original thread that created a view hierarchy can touch its views.

    在分析Android消息机制之前,我们先来看一段代码: public class MainActivity extends Activity implements View.OnClickListen ...

  6. 错误:Only the original thread that created a view hierarchy can touch its views——Handler的使用

    在跟随教程学习到显示web页面的html源码时报错:Only the original thread that created a view hierarchy can touch its views ...

  7. 子线程调用invalidate()产生“Only the original thread that created a view hierarchy can touch its views.”原因分析

    目录 1.异常出处 2.从View.invalidate()方法开始分析 3.ViewRootImpl如何与View进行关联:从Activity的setContentView开始分析 3.1 最顶层的 ...

  8. andriod 错误:Only the original thread that created a view hierarchy can touch its views——Handler的使用

    package com.example.yanlei.myapplication; import android.media.MediaMetadataRetriever; import androi ...

  9. 解决Only the original thread that created a view hierarchy can touch its views

    这种异常出现在子线程中处理UI操作产生的异常,将UI操作放在主线程中就OK了

随机推荐

  1. multiple definition of 问题解决方法

    在最近的项目里,由于我想重载结构体的==操作符,然而大意的我把重载的过程写在了头文件里,所以导致了multiple definition of的错误.现在总结下解决方法: 首先,最关键的,不要把全局变 ...

  2. parameter server学习

    关于parameter server的学习: https://www.zybuluo.com/Dounm/note/517675 机器学习系统相比于其他系统而言,有一些自己的独特特点.例如: 迭代性: ...

  3. TPC-E在populate测试Database时需要注意的一些事项

    第一,  安装时不要使用named instance, 默认的instance就好. 否则会报连不上Database. 第二, TPC-E工具文件夹的完整路径中不可以有空格, 否则会在generate ...

  4. 【Gson】简介 文档 基本使用 示例

    简介 new TypeToken<List<Person>>() {}.getType() 1 1   1 new TypeToken<List<Person> ...

  5. Decorator Wrapper 装饰模式 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  6. IOS 实现界面本地化(国际化)

    在制作应用程序的时候,可以使用本地化功能,将应用程序的内容翻译成多种语言,在不同的区域显示不同的语言.下面就通过简体中文本地化设置来讲解一下本地化的简单使用. 一.让应用程序支持中文语言环境 选择需要 ...

  7. Jenkins——应用篇——插件使用——Publish over SSH

    本文是jenkins应用系统文章的一部分,大部分来自工作和学习中的实践,部分内容来自官方文档和网友的文章,引用的文章会在"參考资料"部分附上原始链接,如无意中侵犯您的权利.请联系Q ...

  8. 【HBase】学习笔记

    HBASE 1 简介 1.1 官网 1.1.1 http://hbase.apache.org/ 1.1.2 Apache HBase™ is the Hadoop database, a distr ...

  9. cognos report上钻下钻报表处理方法(1)

    cognos  report开发中追溯行为,也可以称为上钻下钻行为大致遇到了两种情况 第一种:根据当前报表样式在维度范围内上钻下钻. 第二种:给追溯行为指定报表,传递参数. 可能还有其他情况,这里就不 ...

  10. [Algorithm] Meeting hour optimization (Kanpsack problem) and Dynamic programming

    For example we have array of meeting objects: const data = [ { name: }, { name: }, { name: }, { name ...