[android-developers] Re: ViewHolder Pattern leaking a Context on retained Fragments
As a temporary fix, you can use WeakReference to hold the references
to your views without leaking/retaining them.
This is similar to the GC-wary use of WeakReference in callbacks and
listeners: use WeakReference<YourObject> when you pass your object's
reference to another object whose lifetime may be longer than the
referenced object (YourObject).
That way, your object can be garbage collected even if some listener
or callback (or other holder) holds a weak reference to it.
Joe
On Oct 4, 6:06 am, luciofm <luci...@gmail.com> wrote:
> > > So, here is my question again, there is some way to use the ViewHolder
> > > pattern on this case?
>
> > It should work fine. Row widgets hold references to their ViewHolder
> > via setTag(). Those row widgets are discarded on a configuration
> > change, which in turn discards their ViewHolders. The list is newly
> > populated by the ListAdapter, creating all new ViewHolder instances
> > for the all-new row widgets.
>
> It seems to be the implementation of the HorizontalListView that I'm using (http://www.dev-smart.com/archives/34) that apparently is not discarding the
> tagged rows (If I dont use the ViewHolder pattern, there is no leak).
>
> There is another implementation of Horizontal ListView available?
>
>
>
>
>
>
>
> > --
> > Mark Murphy (a Commons Guy)
> >http://commonsware.com|http://github.com/commonsguy
> >http://commonsware.com/blog|http://twitter.com/commonsguy
>
> > Android App Developer Books:http://commonsware.com/books
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home