带有 setContentView 的 Android ProgressDialog

Android ProgressDialog with setContentView(带有 setContentView 的 Android ProgressDialog)

本文介绍了带有 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

基础教程推荐