开发者

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().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜