ProgressDialog 不会在我的异步任务中显示 onPreExecute?
我查看了一些问题,但没有回答我遇到的问题。
我有这个 asyncTask...
private class LoadData extends AsyncTask<Void, Void, Void>{
protected Void onPreExecute(Void...arg0){
super.onPreExecute();
ProgressDialog dialog = ProgressDialog.show(shoppingClass.this, "",
"Loading. Please wait...", true);
dialog.show();
return null;
}
@Override
protected Void doInBackground(Void... params) {
item = we.getText().toString();
getUserPreference();
itemLookup.loadUrl(url);
return null;
}
@Override
protected void onPostExecute(Void notused){
itemLookup.setVisibility(View.VISIBLE);
}
}
问题是 progessDialog 没有显示?我不知道为什么......我所做的一切都是根据文档编写的。
Ive looked at some questions and non answer the problem im having..
I have this asyncTask...
private class LoadData extends AsyncTask<Void, Void, Void>{
protected Void onPreExecute(Void...arg0){
super.onPreExecute();
ProgressDialog dialog = ProgressDialog.show(shoppingClass.this, "",
"Loading. Please wait...", true);
dialog.show();
return null;
}
@Override
protected Void doInBackground(Void... params) {
item = we.getText().toString();
getUserPreference();
itemLookup.loadUrl(url);
return null;
}
@Override
protected void onPostExecute(Void notused){
itemLookup.setVisibility(View.VISIBLE);
}
}
The problem is the progessDialog is not showing up? I dont know why...Im doing everything write according to the documentation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您没有正确覆盖该方法。将 onPreExecute 更改为:
You are not overriding correctly the method. Change onPreExecute to this:
可能只是 doinbackground 完成得太快,您无法看到该对话框。
it could just be that doinbackground is completing too quickly for you to be able to see the dialog.
检查 shoppingClass.this 是否具有 UI 上下文。另外,您不必对其调用 .show() 两次,也不必返回 null 作为其 void(小写)。
Check that shoppingClass.this has the UI context. Also, you shouldn't have to call .show() twice on it and you don't have to return null as its void (lowercase).