这个例子很简单,打开线程处理任务变得很轻松:
final ProgressDialog dialog = ProgressDialog.show(this, "Title", "Message", true); final Handler handler = new Handler() { public void handleMessage(Message msg) { dialog.dismiss(); } }; Thread checkUpdate = new Thread() { public void run() { // // YOUR LONG CALCULATION (OR OTHER) GOES HERE // handler.sendEmptyMessage(0); } }; checkUpdate.start();