我正在使用 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
、用于完成图标的 ImageView
和 TextView
组成的消息。更改状态时切换图标和进度条的可见性。
关于android - 使用 AsyncTask 在 onPostExecute 中 setIndependentDrawable() ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21306069/