Handler myHandler = new Handler() { |
public void handleMessage(Message msg) { |
switch (msg.what) { |
case 0 : |
textView1.setText(html); |
progressDialog.dismiss(); |
break ; |
case 1 : |
textView1.setText( "《致我们终将逝去的青春》" ); |
progressDialog.dismiss(); |
break ; |
} |
super .handleMessage(msg); |
} |
}; |
new Thread() { |
public void run() { |
Message msg = myHandler.obtainMessage(); |
try { |
html = HttpUtil.fromHtml(HttpUtil |
.getHtml( "http://yuncode.net" )); |
msg.what = 0 ; |
} catch (Exception e) { |
e.printStackTrace(); |
msg.what = 1 ; |
} |
|
myHandler.sendMessage(msg); |
} |
}.start(); |
初级程序员
by: 小箱子 发表于:2014-03-12 13:32:05 顶(0) | 踩(0) 回复
学习
回复评论