【发布时间】:2019-01-19 11:29:58
【问题描述】:
我的 AsyncTask 扩展类中有一个进度对话框。 我已经使用 setcontentview() 将布局设置为进度对话框。 我想更改进度对话框的设计并在完成时显示 2 秒(即在 PostExecute() 中)。
我在 onPreexecute() 中启动进度对话框并在 onPostexecute() 方法中将其关闭。
这就是我在 onPreexecute 中初始化进度对话框的方式
progressDialog = ProgressDialog.show(context, null, null);
progressDialog.setContentView(R.layout.progress_meditate);
progressDialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
progressDialog.setProgressDrawable(new ColorDrawable(Color.WHITE));
我在 onPostExecute 中尝试了以下代码
progressDialog.setContentView(R.layout.progress_complete);
sleep(2000);
progressDialog.dismiss();
但它不起作用。我的 progress_complete 布局未显示。使用相同设计的睡眠时间后,进度对话框将被关闭。
【问题讨论】:
-
不要尝试更改 setcontentview ,取那个视图并更改视图的背景。
-
设置后如何从进度对话框中查看?
-
View view = inflater......,然后是progressDialog.setContentView(view),然后是view.setbackground或者改变特定的view。
-
试过了。不工作。 :-(
-
然后创建两个进度对话框,一个在另一个之上,在 2 秒后关闭另一个。它会工作
标签: android layout progressdialog