开发者

Progress dialog not shown on UI thread until another thread finishs

开发者 https://www.devze.com 2023-04-01 07:19 出处:网络
could someone tell me why the ProgressDialog in the following code isnt displayed on the UI until after the thread completes?

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

精彩评论

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

关注公众号