android 线程 弹出对话框
android 线程 弹出对话框
多线程,在线程中用handler实现弹出对话框
Handler handler = new Handler()
{
public void handleMessage(Message paramMessage)
{
comm.showDialog("添加成功!", ShopAddActivity.this);
}
};
new Thread(){
@Override
public void run()
{
handler.sendMessage(localMessage);
}.start();
要用handler,否则会报错Can't create handler inside thread that has not called Looper.prepare() 因为在Android中不能在子线程中来刷新UI线程,而可以在子线程中添加hander来发送消息更新线程。
猜你喜欢
转载自lizhuohuang.iteye.com/blog/1777025
今日推荐
周排行