//当加载数据或有耗时操作时 用异步加载(有效防止anr5秒异常即主线程阻塞)
package qewrqerqr.wret;
import android.os.Handler;
//异步加载
public abstract class MyAsynocTask {
private Handler handler= new Handler(){
public void handleMessage(android.os.Message msg) {
postTask();
};
};
public abstract void preTask();
public abstract void doinTask();
public abstract void postTask();
public void execute(){
preTask();
new Thread(){
public void run() {
doinTask();
handler.sendEmptyMessage(0);
};
}.start();
}
}