Android开发之在子线程中使用Toast
时间:2015-07-10 15:08:57
收藏:0
阅读:395
在子线程中使用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,所以会抛出异常
原文:http://www.cnblogs.com/liyiran/p/4635676.html
评论(0)