Progress dialog not shown on UI thread until another thread finishs
could someone tell me why the ProgressDialog in the following code isnt displayed on the UI until after the thread completes?
Common.prog = ProgressDialog.show(cContext, "Please wait", "Checking Voucher...", true);
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
Common.prog.dismiss();
开发者_如何学运维 }
};
Thread searchThread = new Thread() {
public void run() {
processCoupon(voucherCodeEditText.getText().toString());
handler.sendEmptyMessage(0);
};
};
searchThread.run();
Thanks in advance :)
call start() method :
searchThread.start();
run() method don't execute Runnable in new Thread.
if you want return to UI thread use runOnUiThread().
精彩评论