【发布时间】:2012-06-18 14:14:16
【问题描述】:
我正在从文件中读取数据 -> 保存到数据库中 -> 通过从数据库中获取数据来加载我的自定义列表视图。在获取数据并将数据保存到数据库时,我希望 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 没有出现在屏幕上,我在代码中添加的任何其他内容或我需要做的任何修改,请帮助我...
注意:当忘记调用dismiss();在 ListView 加载后出现 Type 1 Progress 并旋转无限时间..
【问题讨论】:
-
使用异步任务来获取、保存在数据库中并在列表视图中设置。在异步任务的预执行中启动您的警报对话框并在执行后关闭您的对话框
-
谢谢,我的代码中是否有任何线程问题,我无法指出请帮助我
标签: android multithreading progressdialog