thebaj (3) [Avatar] Offline

I'm new to Android Development and working through Android in Practice.

In code listing 4.8, there is a line:

View listItem = super.getView(position, convertView, parent);

Later on, the code checks for a previously stored View object from listItem.getTag() method.

Where I am confused is I had the impression the the getView method populates data into the view and returns it. So, if in a prior call we used listItem.setTag(), then how can we be sure the the listItem returned by super.getView still has this data stored? Couldn't it be re-using/re-purposing some other View object, not necessarily the one we called setTag on?

Also, the ViewHolder pattern is supposed to save a call to findViewById. What if later on, the super class implementation changes to use its own ViewHolder pattern? Wouldn't we have a problem using the getTag, setTag methods in the MovieAdapter class?

Thank you
thebaj (3) [Avatar] Offline
Re: Listing 4.8 Questions about ViewHolder pattern and convertView