java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
来源:互联网 发布:php取字符串的某个值 编辑:程序博客网 时间:2024/06/05 21:13
1.问题现象
运行程序时,进行某个操作后,程序异常终止并退出,出现一个“很抱歉,XXX已停止运行”的提示,查看"LogCat"发现在红色字体显示的错误行中有一行是:“java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()”
2.解决方案
出现这个问题的原因是因为:把UI的处理操作放到了线程中,如Timer或者Thread的run()方法中处理。如下图
解决的方法就是将UI的操作放到Handler中去处理。
0 0
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- Android java.lang.RuntimeException: Can\'t create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- java.lang.RuntimeException:Can't create handler inside trhead that has not called Looper.prepare
- POJ 1251 Jungle Roads(超裸MST)
- Java基础学习
- uva104 - Arbitrage 最小转移步数
- 黑马程序员-银行业务调度系统
- 开源分布式文件系统----mooseFS
- java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
- 九度OJ 1062: 分段函数
- XML Indexing
- BP反向传播算法
- 遍历一个数组
- Java学习中循环语句的学习
- 购物网站收藏功能分析比较
- ASCII码表
- 如何获取新浪微博数据