Android深入浅出学习笔记之多线程及异步处理(3)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-17 14:39 点击:次
}
//在PreExcute执行后被启动AysncTask的后台线程调用,将结果返回给UI线程
@Override
protected String doInBackground(String... params) {
// TODO Auto-generated method stub
StringBuffer sb=new StringBuffer();
for (String string : params) {
sb.append(string);
}
return sb.toString();
}
}
//用于线程间通信的Handler
class TestHandler extends Handler
{
public TestHandler(Looper looper) {
super(looper);
// TODO Auto-generated constructor stub
}
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
System.out.println("123");
txView.setText((String)msg.getData().get("tag"));
super.handleMessage(msg);
}
}
//后台线程类
class TestThread extends Thread
{
Activity activity;
public TestThread(Activity activity) {
this.activity = activity;
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>