0

I am getting URL string of image in one response, Then i am downloading those images and converting tobitmaps then displaying in listview. Here my question is in future listview items may increase upto 50000,in this case how can i handle data in listview for smooth scroll without giving ANR Exception.Please provide some sample code.

  • You seem to miss the whole point of a `ListView`. You know, view recycling etc... – Xaver Kapeller Aug 08 '14 at 11:31
  • You can also Use [LruCache](http://developer.android.com/reference/android/util/LruCache.html) – SilentKiller Aug 08 '14 at 11:33
  • 1
    http://stackoverflow.com/questions/25077177/outofmemoryexception-load-bunch-of-images-from-server refer to this.. – Pragnesh Ghoda シ Aug 08 '14 at 11:34
  • IMHO, there is no valid reason to have a `ListView` with 50,000 rows in it. Users are going to hate you (with the fiery passion of 1,000 suns) if you are expecting them to swipe their finger hundreds of times and read 50,000 rows to find the right one. Data sets anywhere near this size need to be navigated via some sort of search or filtering mechanism, so the `ListView` length remains something that the user can actually use. – CommonsWare Aug 08 '14 at 12:21

2 Answers2

0

Dont Load All Images At a Time.... It will cause OutOfMemoryException..you can load images in number of pages from URL....

To download images from URL you can use Picasso library... It helps you to avoid OutOfMemoryException and store cache of images too..

You can use LAZY LOAD... and you can try this code for download images...

Picasso.with(context).load(URL).fit().centerCrop().into(imageView);
Pragnesh Ghoda シ
  • 8,318
  • 3
  • 25
  • 40
0

Simple answer dont make a listview so big. 50K elements in a single screen is never a good idea in any scenario(web, desktop or mobile). My suggestion is to have some sort of pagination just like in websites. As for the images like @Prag suggested above use lazy loading for showing images. In my app I used Universal Image Loader and find it extremely useful for showing a large number of bitmaps.

Illegal Argument
  • 10,090
  • 2
  • 44
  • 61