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();
}
});
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.
progressdialog.setVisible(false);
if pricessdialog instanse of JDialog
Call progressdialog.dismiss();
from the main thread;
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.
The process dialog can also be dismissed by calling following method.
progressdialog.cancel();
精彩评论