how can we html.fromhtml to load image from web and set into imageview ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Asynchronous Image Downloading
First thing to do is to make sure you request permission to download images inside the manifest file.
Then, to download an image from the web we need to open an HTTP connection, download and return the image. This method should go inside the activity.
Then we would then add the downloaded image to the ImageView
However, this isn’t asynchronous.
Normally we would create a thread to do some background work but a thread can’t update a view it didn’t create.
To solve this problem we can use AsyncTask. I’ve written this little inner class that extends AsyncTask.
}
The three types used by AsyncTask are
sent to the task upon execution.
So to replace the old code we can now use
This got a lot longer than I planned. The codes not perfect but I hope it’s helped you.
Note: This was is based on Connecting to the web at DevX
References
http://www.devx.com/wireless/Article/39810/1954
http://developer.android.com/reference/android/os/AsyncTask.html