0

hi i have a problem with a android app. i have a list which contains a bitmap and a string.

the bitmap is always generated via the BitmapFactory. I dont have this in a own thread, so when the list gets long, the loading of the page takes a lot of time.

now my question:

what is the easyest way to make this smooth for the user so he dont have to wait. the best way would be to show the strings first and then show a loading bar fpr each bitmap and then generate it one after the other.

but should i make this with one additional thread or one thread for each image?

gurehbgui
  • 14,236
  • 32
  • 106
  • 178

2 Answers2

0

Look at the following thread:

Lazy load of images in ListView

Specifically this answer: https://stackoverflow.com/a/3068012/586859

What you are looking for is commonly labeled "Lazy Loading". This thread contains a method to even cache images you are downloading for faster image loads. I would recommend optimizing your ListView using ViewHolder, and utilize an adapter similar to the ones found in that post to achieve a smoother view.

Community
  • 1
  • 1
burmat
  • 2,548
  • 1
  • 23
  • 28
0

If there are a lots of pictures you can not create a thread for each image because it will throw Exception. The simplest Android way is to create one AsyncTask for these job or a local service with background thread if there are a lot of files. If you want more elegant way you can use java.util.concurrent.*; and create a thread poll for this job.

Alex
  • 379
  • 4
  • 14