0

I have a listview which contains ImageView i. Now I have an array list which contains URLS inside it like www.abc.jpg, www.def.jpg and so on. Now I want to insert these URLs as the source for the image view. Is it possible.?

Aishvarya Jaiswal
  • 1,793
  • 6
  • 34
  • 72

2 Answers2

0

ImageView doesn't have any API that allows setting of urls that will be downloaded later on. You need to separately from the ImageView setup an asynchronous task that will download this image from the url, convert it to a Bitmap and then set it on ImageView with setImageBitmap(Bitmap).

Maciej Pigulski
  • 1,562
  • 12
  • 26
0

As noted, you're doing network I/O in the main thread. The stack trace identifies it as happening in onPostExecute. In there, I see this code:

BitmapFactory.decodeStream(newurl.openConnection() .getInputStream()

That certainly looks like network I/O to me.

What I'm wondering is, you've got this lovely worker thread already, but you're doing a lot of work in onPostExecute() (main thread). To prevent janky UI, I suggest you move as much of that computation into doInBackgroud() as possible.

Sparky
  • 8,437
  • 1
  • 29
  • 41