我试图在下载数据的过程中显示进度对话框。Android UI冻结而不是显示ProgressDialog
眼下,这就是我:
final ProgressDialog pd = ProgressDialog.show(this, "Updating", "Loading...");
Thread td = new Thread(new Runnable(){
public void run(){
//time consuming download
pd.dismiss();
}
});
td.start(); // start the thread and use join to wait for it to return
td.join(); //wrapped in try catch not shown here
我不需要从下载进度的更新,直到数据被下载的应用程序不应该做任何事情,这就是为什么我使用加入 - 所以它会等待下载完成。
我得到的结果是
- 按下按钮
- UI冻结
- 进度对话框闪烁和关闭,下载完成
我需要的是
- 按钮
- 进度对话框显示
- 进度对话框关闭,下载完成。
任何想法为什么它不马上显示,而是在完成时闪烁和熄灭?
为什么downvote?我想在这里学习。我的问题不好吗? – xdumaine
+1我在这里没有看到有什么理由为此付出代价! – Knickedi