android - 使用 AsyncTask 在 onPostExecute 中 setIndependentDrawable() ?

标签 android android-asynctask progressdialog

我正在使用 AsyncTask ProgressDialog 来显示一些消息。处理时它有一个图像而不是旋转的圆圈。我已在 onPreExecute 中将其设置为:-

Drawable myIconStart = getResources().getDrawable(R.drawable.imagestart);
this.dialog.setIndeterminate(true);
this.dialog.setIndeterminateDrawable(myIconStart); 
this.dialog.setMessage("Processing… please wait for confirmation");

现在,当工作完成后,在 onPostExecute 中,我设置为:-

Drawable myIconDone = getResources().getDrawable(R.drawable.imagedone);
            this.dialog.setIndeterminate(true);
            this.dialog.setIndeterminateDrawable(myIconDone);
            this.dialog.setMessage("Your Reservation has been confirmed");

但是,onPostExecute 处的第二个图像尚未设置。第一个图像出现然后消失,第二个图像显示为空白。你能告诉我我做错了什么/我应该做什么吗?

最佳答案

似乎不确定的可绘制对象确实无法被替换。

根据您的要求,请考虑编写一个自定义对话框,其布局由 ProgressBar、用于完成图标的 ImageViewTextView 组成的消息。更改状态时切换图标和进度条的可见性。

关于android - 使用 AsyncTask 在 onPostExecute 中 setIndependentDrawable() ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21306069/

相关文章:

android - 从 AsyncTask 更新 Activity 中的进度对话框

java - 使用 ProgressDialog 和 Threads 时应用程序崩溃

java - 如何在Android中添加向firebase添加数据的进度对话框?

java - 单击项目导致 IllegalStateException

java - Android应用程序通信串口数据

android - 在 ViewModel 类中使用新线程

android - AsyncTask 引起的 NotSerializableException

java - Google Analytics 在运行时抛出 NoClassDefFoundError

android - 保存为草稿未发送的邮件

android - ListView : Android 中第一行的默认选择