对App进行开发测试时,偶尔出现app崩溃的问题.日志如下: 10-25 18:44:52.935 15290-15290/com.zzq.cnblogs E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: com.zzq.cnblogs, PID: 15290 java.lang.IllegalStateException: The content of the adapter has changed but ListView did not re…
在android开发过程中,耗时操作我们会放在子线程中去执行,而更新UI是要主线程(也叫做:UI线程)来更新的,自然会遇到如何更新主线程UI的问题.如果在主线程之外的线程中直接更新页面显示常会报错.抛出异常:android.view.ViewRoot.CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. 为什么要有handler机制?h…
转:http://blog.sina.com.cn/s/blog_3fe961ae0100mvc5.html 在Android平台下,进行多线程编程时,经常需要在主线程之外的一个单独的线程中进行某些处理,然后更新用户界面显示.但是,在主线线程之外的线程中直接更新页面显示的问题是:系统会报这个异常: ERROR/AndroidRuntime(1222): android.view.ViewRoot$CalledFromWrongThreadException: Only the original…
今天在做练习时,在一个新开启的线程中调用“Toast.makeText(MainActivity.this, "登陆成功",Toast.LENGTH_SHORT).show();” 报错为:Can't create handler inside thread that has not called Looper.prepare() 在新线程中添加Looper.prepare();和Looper.loop();即可. 示例代码段:(该代码在新开的线程中) Looper.prepare()…
public class TransferTools { private static final int MSG_START = 1001; private static final int MSG_TRANSFERRING = 1002; public void setTransferListener(TransferListener mListner) { mTransferListener = mListner; } public interface TransferListener {…