[英]Unable to show progress bar before displaying data into listview inside Dialog
[英]Show Progress Dialog before loading ListView contents
我正在从文件中读取数据 - >保存到数据库 - >通过从数据库中提取数据来加载我的自定义ListView ..在获取和保存数据到数据库时我想在我的屏幕上显示ProgressDialog我尝试了这两种类型,但它不是工作的
类型1:
AlertDialog alertDialog = AlertDialog.show(CommoditiesListScreen.this, "Importing...");
// importing data from file
// Saving data to the DB
alertDialog.dismiss();
类型2:
UiDialog uiDialog = new UiDialog(CommoditiesListScreen.this);
CommoditiesListScreen.this.runOnUiThread(uiDialog);
AlertDialog alertDialog = AlertDialog.show(CommoditiesListScreen.this, "Importing...");
alertDialog.getWindow().makeActive();
// importing data from file
// Saving data to the DB
uiDialog.stopDialog();
alertDialog.dismiss();
我尝试了两种方式它不工作,ProgressDialog没有出现在屏幕上,我添加的任何其他东西或我在我的鳕鱼eplease做的任何修改帮助我...
注意:Forgot call dismiss(); 在ListView加载后出现类型1进度,它旋转无限时间..
这是使用AsyncTask
的理想情况,您可以在方法onPreExecute()
显示dialog
,在方法onPreExecute()
中执行后台操作(从文件读取数据 - >保存到DB doInBackground()
并加载并显示列表onPostExecute()
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.