You don't understand what I mean. The problem is that in getView() I make a call to fetch the bitmap from remote. And if getView() is calles multiple times for one position, this call will be made multiple times, and the resulting bitmap will be instantiated multiple times. If I recycle the view/use convertView or not doesn't make a difference (for this issue).
BTW, I have already a bitmap cache, which solves the problem after having fetched the bitmaps the first time. But my problem is about the first time creating many bitmaps (e.g. first 4 positions visible -> bitmaps for item 0, item 1, item 2, item 3 -> 16 bitmaps, and I just needed 4). On Monday, August 13, 2012 4:14:30 PM UTC+2, bob wrote: > > Why not use the convertView parameter to getView? > > On Monday, August 13, 2012 8:45:15 AM UTC-5, user123 wrote: >> >> Hi, >> >> I have a big problem with bitmaps and the listview's behaviour of calling >> getView() on each position multiple times. >> >> My list contains only bitmaps and fetches them asynchronously from a >> remote location. Now, when the listview is displayed, since getView() is >> called about 4 times for each position, it will instantiate 4 different >> bitmap instances for the same position (and use only one...), and this >> causes out of memory error. >> >> I already tried out some strategies to solve this, like implementing a >> list of "waiting" imageViews, and fetch only for one, and then set the >> bitmap for all the waiting ones, but this generated new problems and it's >> also difficult to synchronize. >> >> I tried also adding a list-field with already fetched positions of the >> listview, in order to fetch and set only once, but it seems to generate a >> different image view each time (I'm recycling convertView, but anyways), >> since I end with empty positions (although all the bitmaps where fetched, >> instantiated and set in one of the imageviews). >> To solve this I used a map-field which maps position to List<ImageView>, >> and set the bitmap to all the imageViews which where called for one >> position. Should work, but it also doesn't. In most positions I get the >> correct bitmaps, but, for example, in the first position of the list, I get >> the bitmap from the last visible position (I can see it switches fast, >> first it shows bitmap from position 0, then 1, then 2, and then 3 -my last >> visible position-). >> >> Any solution? Thanks in advance. >> > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

