Hi Mark,

I think I got it now :)

Thanks a bunch for all your help.

Regards.

On Jul 1, 2008, at 4:19 PM, Mark Murphy wrote:

>
>> Can you please also clarify what do you mean by "use the same  
>> instance
>> as the convertView" parameter? Dont I need a new View instance for
>> every cell being displayed? i.e., if displaying 5 TextView rows at  
>> the
>> same time, then do we need need 5 different instances of TextView? OR
>> is it the case that the getView() method is called only when the View
>> is about to be drawn and therefore a single instance will suffice for
>> displaying the whole list ?
>
> Ideally, Android and your activity will only create as many row  
> Views as
> can be physically displayed by the ListView.
>
> Suppose you have an Adapter that wraps a set of 50 objects, but the
> ListView only has room to show 7 of those at a time. When your  
> activity
> launches, I believe your Adapter will have getView() called 7 times  
> with a
> null convertView, which you will wind up populating with the first 7
> objects' data out of the 50 available objects. Then, if the user  
> scrolls
> the ListView, your getView() will start being called with convertView
> sometimes being non-null, meaning the ListView wants to fill in an
> existing row's View with new data.
>
> I imagine the precise details on when getView() will be called with a
> possible-to-recycle convertView will vary as Android evolves.  
> However, if
> you get a non-null convertView, Android is asking you to recycle  
> that View
> if possible. Either return convertView (after modifying the contents  
> to
> reflect the data identified by the supplied position), or return a
> brand-new View, as your activity sees fit.
>
> At the outset, it may be simplest to ignore convertView and just  
> inflate
> new Views on each getView() call. If performance suffers, you can  
> always
> try reusing convertView.
>
> -- 
> Mark Murphy (a Commons Guy)
> http://commonsware.com
> _The Busy Coder's Guide to Android Development_ -- Available Now!
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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
[EMAIL PROTECTED]
Announcing the new M5 SDK!
http://android-developers.blogspot.com/2008/02/android-sdk-m5-rc14-now-available.html
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to