I need to download an image in an ImageView
. I want to use a ProgressBar
to tell the user that the program is downloading images. If the program can't download the image in 30sec, the program will use a Toast
/AlertDialog
to notify the user and exit.
How can I implement this function? Could anyone give me some advice on how to build the framework? I can complete the details. Do I need thread? / AsyncTask?
Yes, you do need to download the image in AsyncTask (I am assuming that you are downloading from URL). Effectively to achieve your functionality this is what you need to do:
Below is the pseudocode/skeleton of what the steps that I mentioned above (didn't check for syntax, so I apologize for any error)
Maybe this helps a little bit.
The code for the progress bar you can find here.
I hope you are trying to download an image from a known url, am i right? If so please have a look at this url
Hope that helps you...
You could also see this. It will cover the process of downloading the image to the phone as well as providing loading threads while the image is being downloaded.