【问题标题】:setIndeterminateDrawable() in onPostExecute using AsyncTask?使用 AsyncTask 在 onPostExecute 中设置 IndeterminateDrawable()?
【发布时间】:2014-01-23 10:54:04
【问题描述】:

我正在使用 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 的第二张图片。第一个图像出现然后消失,第二个图像显示为空白。你能告诉我我做错了什么/我应该做什么吗?

【问题讨论】:

  • 客户要求已经改变,现在我必须先显示一个处理微调器,然后在执行后我必须显示第二个图像
  • 由于时间限制,我只是按照laalto的建议进行。但仍然不明白为什么会这样。

标签: android android-asynctask progressdialog


【解决方案1】:

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

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

【讨论】:

  • 嗨 laalto,您是否知道,图片没有出现在 PostExecute 上的原因可能是什么?
  • 并非如此。昨天我花了一些时间调试它,但放弃了,并决定如果您需要类似的结果,最好将方法更改为自定义对话框。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-30
  • 2012-09-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多