Android ProgressDialog with setContentView

I read a lot about this and do not see anyone who would have done this or tried it before.

So, I have an object that extends ImageView, and then in it I call up the progress dialog and set the contents of the progress dialog to the image (i.e. I'm trying to draw a run dialog in the image view.).

loadingProgressDialog.setContentView(this); //this is: LoaderImageView extends ImageView loadingProgressDialog.setIndeterminate(true); loadingProgressDialog.show(); 

And I get the error: requestFeature () needs to be called before adding content

Now I have seen this error before on message loads, and yes the answer seems obvious. I tried to install all the functions:

 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 at first I don’t understand why I need this? And secondly, none of them work!

So the question is, can I set the ContentView for WindowView in ImageView? If so, what did I get wrong?

+7
android imageview progressdialog custom-view
source share
3 answers

Got it.

The key was in class names, do not use ProgressDialog ( http://developer.android.com/reference/android/app/ProgressDialog.html ) when you do not need a dialog!

I changed my implementation to use: ProgressBar ( http://developer.android.com/reference/android/widget/ProgressBar.html ) and it works great.

I greet you by the ear!

This is why I looked for it for:

http://www.anddev.org/novice-tutorials-f8/imageview-with-loading-spinner-t49439.html

A tutorial showing how you can use Spinner while loading an image. Enjoy

0
source share

I have done it; in fact, it is very easy; using

 loadingProgressDialog.setContentView(this) 

after

 loadingProgressDialog.show() 

The following lines of code are not needed:

 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); 

to say:

 loadingProgressDialog.setIndeterminate(true); loadingProgressDialog.show(); loadingProgressDialog.setContentView(this); //this is: LoaderImageView extends ImageView 

which is enough.

Hope this helps other people find the answer to this question.

+42
source share

If you read the progressDialog developer’s document, it says, β€œA dialog showing a progress indicator and an optional text message or view. Only a text message or view can be used at a time.”

It looks like you are trying to do both. Perhaps the cause of your problem.

0
source share

All Articles