Skip to content Skip to sidebar Skip to footer

Why We Should Re-assign Values For A Recycled Convertview In Getview()

For example (Xamarin c# example, but concept is same for Android java also): 'data' is the class which holds the data public override View getView (int position, View convertVie

Solution 1:

When a View is recycled, it's not necessarily for the same item of the Adapter (indeed, most of the time, it's not -- the most common example is "item goes outside the view at the top as you scroll down, is reinserted at the bottom"). That's why the values need to be reassigned, because they almost always depend on the value of position, which will not be the same as the last time this view was used.

Your example is a bit trivial insofar as the text of the image are always the same, but this is not the case in most usages of Adapter views.

Post a Comment for "Why We Should Re-assign Values For A Recycled Convertview In Getview()"