realuser
realuser

Reputation: 951

ProgressDialog Problem?

There is a ProgressDialog in my app. It is running but after finishing process does not close. Where is the error, I'm doing. Thanks.

 button.setOnClickListener(new View.OnClickListener() 
    {     
        public void onClick(View v) {            

                progressdialog.show();

                 new Thread(new Runnable() {
                        public void run() {
                            try {                           

                                 // doing something...  

                                progressdialog.dismiss();

                            } catch (Exception e) {
                                e.printStackTrace();
                            }

                        }
                    }).start();         
            }                  
    });

Upvotes: 0

Views: 146

Answers (5)

Kartik Bhatt
Kartik Bhatt

Reputation: 924

The process dialog can also be dismissed by calling following method.

progressdialog.cancel();

Upvotes: 0

Vladimir Ivanov
Vladimir Ivanov

Reputation: 43108

The right way of doing any work in background while showing the progress dialog is using AsyncTask with ProgressDialog bounded. See here. Remember, that you can not modify the UI from the thread, which is not UI thread.

Upvotes: 0

Bosah Chude
Bosah Chude

Reputation: 3810

Call progressdialog.dismiss(); from the main thread;

Upvotes: 0

N-JOY
N-JOY

Reputation: 7635

do this......

button.setOnClickListener(new View.OnClickListener() 
    {     
        public void onClick(View v) {            

                progressdialog.show();

                 new Thread(new Runnable() {
                        public void run() {
                            try {                           

                                 // doing something...  

                               hm.sendEmptyMessage(0);

                            } catch (Exception e) {
                                e.printStackTrace();
                            }

                        }
                    }).start();         
            }                  
    });


    Handler hm = new Handler()
    {
       public void handleMessage(Message msg)
       {

         progressdialog.dismiss();
        }


    }

Thanks.

Upvotes: 1

Penkov Vladimir
Penkov Vladimir

Reputation: 939

progressdialog.setVisible(false);

if pricessdialog instanse of JDialog

Upvotes: 0

Related Questions