Reputation: 951
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
Reputation: 924
The process dialog can also be dismissed by calling following method.
progressdialog.cancel();
Upvotes: 0
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
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
Reputation: 939
progressdialog.setVisible(false);
if pricessdialog instanse of JDialog
Upvotes: 0