how can we html.fromhtml to load image from web and set into imageview ?
相关问题
- Views base64 encoded blob in HTML with PHP
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Is there a way to play audio on a mobile browser w
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
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