Android ProgressDialog with setContentView(带有 setContentView 的 Android ProgressDialog)
问题描述
我已经阅读了很多关于此的内容,但看不到任何曾经做过或尝试过的人.
I've read a hell of a lot about this, and can't see anyone who's done or tried it before.
所以我有一个扩展 ImageView 的对象,然后在其中我调用一个进度对话框并将进度对话框的内容设置为 imageview(即尝试在 imageview..view 中绘制进度对话框.)
So I've got an object that extends ImageView, then within this I call a progress dialog and set the progress dialogs's content to the imageview (i.e. attempting to draw the progress dialog in the imageview..view.)
loadingProgressDialog.setContentView(this); //this is: LoaderImageView extends ImageView
loadingProgressDialog.setIndeterminate(true);
loadingProgressDialog.show();
我得到错误:在添加内容之前必须调用 requestFeature()
And I get the error: requestFeature() must be called before adding content
现在我之前在大量帖子中看到过这个错误,是的,答案似乎很明显.我已尝试设置所有功能:
Now I've seen this error before on loads of posts and yes the answer seems obvious. I've tried to set all the features:
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);
但首先我不明白我为什么需要这个?其次,它们都不起作用!
But first I don't understand why I need this? And second none of them work anyway!
所以问题是我可以将 ProgressDialog contentView 设置为 ImageView 吗?如果是这样,我做错了什么?
So the question is can I set the ProgressDialog contentView to an ImageView? If so what have I gotten wrong?
推荐答案
知道了.
线索在类名中,不要使用 ProgressDialog ( http://developer.android.com/reference/android/app/ProgressDialog.html )当你不需要对话框时!
The clue was in the class names, don't use ProgressDialog ( http://developer.android.com/reference/android/app/ProgressDialog.html ) when you don't need a dialog!
我将实现更改为使用:ProgressBar ( http://developer.android.com/reference/android/widget/ProgressBar.html ),效果很好.
I changed my implementation to use: ProgressBar ( http://developer.android.com/reference/android/widget/ProgressBar.html ) and it works great.
无论如何,为耳朵干杯!
Cheers for the ear anyway!
这就是我寻找它的原因:
This is why I was looking for it for:
http://www.anddev.org/novice-tutorials-f8/imageview-with-loading-spinner-t49439.html
教程展示了如何在加载图像时使用 Spinner.享受
Tutorial showing how you can have a Spinner whilst an image is loading. Enjoy
这篇关于带有 setContentView 的 Android ProgressDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有 setContentView 的 Android ProgressDialog
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01