Putting the bitmap reference in the convertview tag and retrieve the tag when The getview is called could be a solution?
On 17 Ott, 04:41, IcedNet <[email protected]> wrote: > You should look into Romain Guy's 2009/10 Google I/O presentations on > UI -- he is the whip with ListViews/UI. > If you're looking for what I think you're looking to do -- which is > speed up that list view -- he has a view holder pattern that will do > just that. > > Peace, > Dan > > On Oct 16, 10:08 pm, Studio LFP <[email protected]> wrote: > > > > > Based on the code there, you wouldn't have the chance to recycle the bitmap > > as you don't keep a handle to it anywhere. > > > Then again, if the ListView discards that particular row and you aren't > > retaining any handles to the bitmap, then the bitmap should be scheduled for > > collection by the GC. If you did try to retrieve the view that was holding > > the image from the ListView and it did return it to you, there is a good > > chance the ListView still wants to use it and you would not want to release > > the bitmap. > > > Is there a reason you are wanting to try to recycle the bitmap? > > > Also, we are talking about the recycle() function on bitmap and not reusing > > the same bitmap, correct? > > > Steven > > Studio LFPhttp://www.studio-lfp.com > > > On Sunday, October 16, 2011 4:14:48 AM UTC-5, emanuele wrote: > > > > Hello guys.. that s my baseAdapter getview implmentation: > > > > @Override > > > public View getView(int position, View convertView, ViewGroup parent) > > > { > > > > int type = getItemViewType(position); > > > if (convertView == null) { > > > switch (type) { > > > case TYPE_BIG_NEWS: > > > convertView = mInflater.inflate(R.layout.big_news, null); > > > break; > > > case TYPE_NORMAL_NEWS: > > > convertView = mInflater.inflate(R.layout.normal_news, null); > > > break; > > > default: > > > break; > > > } > > > } > > > > ImageView thumb = (ImageView) > > > convertView.findViewById(R.id.thumbId); > > > > File f = null; > > > if (filename != null) > > > f = mFileCache.getFile(i.newsKey, filename); > > > if (f == null) { > > > if (mGetThumbsThread != null && filename != null) { > > > Log.i(TAG, "cache miss"); > > > thumbLinks.offer(new ThumbRequest(i.newsKey, i.thumbLink, > > > i.thumbName)); > > > mGetThumbsThread.signal(); > > > } > > > thumb.setImageResource(placeHolder); > > > } else { > > > Log.i(TAG, > > > "file bitmap cached: " + f.getName() + " size: " + f.length() / > > > 1024); > > > bitmap = BitmapFactory.decodeFile(f.getAbsolutePath()); > > > thumb.setImageBitmap(bitmap); > > > } > > > > return convertView; > > > } > > > > Every row is compound of text and an ImageView. Is there any chance to > > > recycle the bitmap I use in the getView? -- 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

