You could, but setTag(int, Object) forces you to use unique ids throughout your app.
On Sat, Apr 30, 2011 at 9:27 PM, Eric <[email protected]> wrote: > In the Google I/O 2010 - The world of ListView talk shown here: > > http://www.youtube.com/watch?v=wDBM6wVEO70&t=17m38s > > a 'ViewHolder' paradigm is suggested to cache views and avoid the > findViewById lookup. Could the same thing be achieved by using the > setTag(id, Object) method on View, and simply use the View's tag map > to store the reference by resource ID? I think this would work, but > would it introduce any memory leak (or other) problems? > > > public static final View getCachedViewByTagId(View parentView, int > viewToFindId) { > Object object = parentView.getTag(viewToFindId); > > if(object == null) { > object = parentView.findViewById(viewToFindId); > > if(object != null) { > parentView.setTag(viewToFindId, object); > } > } > > return (View)object; > } > > -- > 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 > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- 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

