请求网络的过程中显示progressdialog,获取到信息后,handler发消息通知progressdialog
dismiss,结果发现多请求几次progressdialog就消失的很快(一闪而过),纠结了好久没解决,求帮助,
网络请求还没请求完,就关闭了吗?可以设置一个延时关闭。应该就可以解决了。
final ProgressDialog dialog = ProgressDialog.show(this, "",
"请稍等 …", true, true);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(10000);//让他显示10秒后,取消ProgressDialog
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dialog.dismiss();
}
});
t.start();
这样设置下试试,可能你说的第一次获取网络数据的时候慢了些,后面再请求,返回的就快些。
final ProgressDialog dialog = ProgressDialog.show(this, "",
"请稍等 …", true, true);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(10000);//让他显示10秒后,取消ProgressDialog
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
dialog.dismiss();
}
});
t.start();
这样设置下试试,可能你说的第一次获取网络数据的时候慢了些,后面再请求,返回的就快些。
final ProgressDialog proDia = ProgressDialog.show(LoginActivity.this, "登陆中...", "Loading...");
new Thread() {
public void run() {
try {
Thread.sleep(1500);
} catch (Exception e) {
// TODO: handle exception
} finally {
proDia.dismiss();
startActivity(new Intent(LoginActivity.this, MainActivity.class));
}
}
}.start();
我自己在登录界面写的进度对话框,你可以看一下!