Blu*_*ell 7 android progressdialog custom-view imageview
我已经阅读了很多关于此事的内容,并且看不到之前已经完成或尝试过的人.
所以我有一个扩展ImageView的对象,然后在此我调用一个进度对话框并将进度对话框的内容设置为imageview(即尝试在imageview..view中绘制进度对话框.)
loadingProgressDialog.setContentView(this); //this is: LoaderImageView extends ImageView
loadingProgressDialog.setIndeterminate(true);
loadingProgressDialog.show();
Run Code Online (Sandbox Code Playgroud)
我收到错误:必须在添加内容之前调用requestFeature()
现在我在大量帖子之前看到过这个错误,是的,答案似乎很明显.我试图设置所有功能:
loadingProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
loadingProgressDialog.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
loadingProgressDialog.getWindow().requestFeature(Window.FEATURE_PROGRESS);
loadingProgressDialog.getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
Run Code Online (Sandbox Code Playgroud)
但首先我不明白为什么需要这个?第二,他们都没有工作!
所以问题是我可以将ProgressDialog contentView设置为ImageView吗?如果是这样我有什么问题?
小智 43
我做到了; 事实上,这很容易; 运用
loadingProgressDialog.setContentView(this)
Run Code Online (Sandbox Code Playgroud)
后
loadingProgressDialog.show()
Run Code Online (Sandbox Code Playgroud)
以下代码行是不必要的:
loadingProgressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
loadingProgressDialog.requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
loadingProgressDialog.getWindow().requestFeature(Window.FEATURE_PROGRESS);
loadingProgressDialog.getWindow().requestFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
Run Code Online (Sandbox Code Playgroud)
那就是说:
loadingProgressDialog.setIndeterminate(true);
loadingProgressDialog.show();
loadingProgressDialog.setContentView(this); //this is: LoaderImageView extends ImageView
Run Code Online (Sandbox Code Playgroud)
足够了.
我希望这可以帮助其他人寻找这个问题的答案.
知道了。
线索就在类名中,当你不需要对话框时,不要使用 ProgressDialog ( http://developer.android.com/reference/android/app/ProgressDialog.html )!
我更改了我的实现以使用:ProgressBar(http://developer.android.com/reference/android/widget/ProgressBar.html)并且效果很好。
无论如何,为耳朵喝彩!
这就是我寻找它的原因:
http://www.anddev.org/novice-tutorials-f8/imageview-with-loading-spinner-t49439.html
教程展示了如何在加载图像时使用 Spinner。享受