标签:
Activity com.itheima.mobilesafe.activty
后台服务 com.itheima.mobilesafe.service
广播接受者 com.itheima.mobilesafe.receiver
数据库 com.itheima.mobilesafe.db.dao
对象(java bean) com.itheima.mobilesafe.domain/bean
自定义控件 com.itheima.mobilesafe.view
工具类 com.itheima.mobilesafe.utils
业务逻辑 com.itheima.mobilesafe.engine
1.listView
适配器装载原理完成
2.异步加载的原理,
3.把入门到精通的博客看完
4.动画复习
异步加载的原理
为什么在子线程当中不能创建 Handler
,因为在该构造方法当中有如下代码
mLooper = Looper.myLooper();
if (mLooper == null) {
throw new RuntimeException(
"Can‘t create handler inside thread that has not called Looper.prepare()");
}
可以看到构造函数当中有调用了一次Looper
如果为空就会抛出该运行时异常了。注意系统在主线程的时候我们就调用了一次Looper.prepare()
方法了。而该方法的底层作用new Looper()
,
总结:主线程中可以直接创建Handler对象,而在子线程中需要先调用Looper.prepare()才能创建Handler对象。
Looper集体源码解释
Handler
是如何接受消息的的通过sendMessage(msg)
发送消息发送到发送消息方法最终都会辗转调用到sendMessageAtTime()
方法中,这个方法的源代里的意思就是吧该消息放入一个消息队列中MessageQueue
让我们发送的消息以队列的形式存在,而这个类是在Looper
的够着方法中创建的,所以我们一个Looper
就对应了一个MessageQueue
,而他们的排列是靠时间顺序来排列的。
最后
looper.loop
方法会有一个死循环里面调用一个dispatchMessage(msg)
该方法就调用了handleMessage()
这样我们就可以在异步消息里面访问主线程的UI了。
null
Adapter
,而继承了BaseAdapter
,因为Adapter
是一个接口,而BaseAdapter
是继承了该接口的抽象类,实现了Adapter
的部分方法,所以我们在基础BaseAdapter
的时候我们只需要重写BaseAdapter
没有实现的就可以了,不然我们直接继承Adapter
要实现接口里面的所有方法。标签:
原文地址:http://www.cnblogs.com/ganwei/p/4774721.html