这个主要总是,开启的线程和 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. 第二章 eclipse中m2e插件问题

    1.当引入一个maven项目到eclipse中时,这时候可能会出现找不到一个插件的问题,例如: <plugin> <groupId>org.apache.maven.plugi ...

  2. Android中intent如何传递自定义数据类型

    转载自:http://www.cnblogs.com/GoAhead/archive/2012/07/16/2593868.html 大家好,好久不见,今天要给大家讲一下Android中Intent中 ...

  3. 用C#代码编写的SN快速输入工具

    一般软件都要输入序列号(SN),而大家平时用的最多的恐怕是盗版软件,通常盗版软件的序列号(SN)都保存成:XXXXX-XXXXX-XXXX-XXXX的形式. 而软件输入序列号的地方通常都是几个文本框( ...

  4. (转)[unity3d]easytouch的使用

    对于移动平台上的RPG类的游戏,我们常用虚拟摇杆来控制人物角色的行走和一些行为,相信我们对它并不陌生,之前尝试了EasyTouch2.5,发现并没有最新版的3.1好用,2.5版本的对于自适应没有做的很 ...

  5. jquery文字填写自动高度

    下面开始写一个jquery插件 (function($){ $.fn.autoTextarea = function(options) { var defaults={ maxHeight:null, ...

  6. [android错误] requires API level *

    Call requires API level (current min ): android.content.res.Resources#getBoolean 参考文档: http://stacko ...

  7. data directory "/var/lib/postgres/data" has group or world access

    直接拷贝完好的data至pg目录底下,可能引起下面的错误:说data目录权限不是700.FATAL: data directory "/var/lib/postgres/data" ...

  8. base64 图片编码之再优化

    首先进入网站: http://b64.io/ 最多可减少图片体积容量近70%,建议不要优化base 64 图片格式为gif , 已实测如果用gif的话会增加容量.

  9. php之phpstorm入门

    入门篇!见这章

  10. Java从零开始学三十七(JAVA IO- 二进制文件读写)

    一.简述 二.使用步骤 DataInputStream: 引入相关的类 构造数据输入流的对象(如:FileInputStream,BufferedWriter包装后读取文件等) 读取二进制文件的数据 ...