ProgressDialog 仅在 setContentView() 之后触发
我有一个 ProgressDialog:
ProgressDialog pDialog = ProgressDialog.show(MyActivity.this, "", "Logging In...");
它应该从方法的顶部运行直到到达结束。以下是授权成功时执行的块:
if(writeSuccess){
Toast.makeText(getApplicationContext(), "Login Success!", Toast.LENGTH_SHORT).show();
pDialog.dismiss();
setContentView(R.layout.auth);
}
但是 ProgressDialog
不会触发。但是,如果我注释掉它,它将在 ContentView 切换后触发。有人对这个问题有什么想法或解决办法吗?
I have a ProgressDialog:
ProgressDialog pDialog = ProgressDialog.show(MyActivity.this, "", "Logging In...");
And it is supposed to run from the top of the method and through until it reaches an end. Here is the block that is execute on authorization success:
if(writeSuccess){
Toast.makeText(getApplicationContext(), "Login Success!", Toast.LENGTH_SHORT).show();
pDialog.dismiss();
setContentView(R.layout.auth);
}
But the ProgressDialog
will not fire. But if I comment out it's dismissal it will fire after the ContentView has been switched. Anybody have any idea or remedy to this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 ASyncTask 来做你想做的事情。在 onPreExecute 上,创建并显示对话框,在 doInBackground 上进行登录,在 onPostExecute 上关闭先前创建的对话框。
Use an ASyncTask to do what you want. On onPreExecute, create and display the dialog, on doInBackground, make your Login, and on onPostExecute dismiss the dialog previously created.