首页 > 移动平台 > 详细

Android开发之在子线程中使用Toast

时间:2015-07-10 15:08:57      阅读:398      评论:0      收藏:0      [点我收藏+]

在子线程中使用Toast的时候,出现Force close。

错误提示:Can‘t create handler inside thread that has not called Looper.prepare()

解决方法:

1 Looper.prepare();
2 Toast.makeText(ActivityTestActivity.this, "toast", 1).show();
3 Looper.loop();

原因:

子线程只是一个普通的线程,其ThreadLoacl中没有设置过Looper,所以会抛出异常

Android开发之在子线程中使用Toast

原文:http://www.cnblogs.com/liyiran/p/4635676.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!