>
> Interesting…  I usually just create a new View every time in getView…  so
> I've never run into that.
>
That should be fine if you don't have a lot of items or if your views are
kept very simple.... Otherwise doing this will cause choppiness when
scrolling the listview.

Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Sat, Jul 28, 2012 at 2:20 PM, soynerdito soynerdito <[email protected]
> wrote:

>  A nice post describing that is here
> http://lucasr.org/2012/04/05/performance-tips-for-androids-listview/
> With an example of what is called a view holder to have a performance
> improvement.
> Also in the Google IO 2010 it is well explain from the developer itself
> http://www.youtube.com/watch?v=wDBM6wVEO70
>
>
>
> On Sat, Jul 28, 2012 at 2:41 PM, bob <[email protected]> wrote:
>
>> Interesting…  I usually just create a new View every time in getView…  so
>> I've never run into that.
>>
>>
>>
>> On Saturday, July 28, 2012 6:10:50 AM UTC-5, Sergio Panico wrote:
>>>
>>> Hi all,
>>> I thank all for your answers.
>>>
>>> I've understood the "strange" behaviour that doesn't makes my ListView
>>> to refreshes correctly.
>>>
>>> Here is the link where I've found the solution:
>>> https://groups.google.com/**forum/?fromgroups#!topic/**
>>> android-developers/2Ub4yhyKumM<https://groups.google.com/forum/?fromgroups#%21topic/android-developers/2Ub4yhyKumM>
>>>
>>> This topic clearly explains that, when the callback method "getView" is
>>> called, the parameter "convertView" is null only when ListView tries to
>>> draw the first 5 items, from "A" to "E". When I scroll down the content of
>>> the list, and the ListView draws the items 6 and 7, it "reuses" the views
>>> previoulsy created, hence "convertView" is not null and my getView
>>> implementation goes into "else" branch.
>>>
>>> What I've missed was to bind the "old" view, with the "new" model item
>>> getting showed. So the fix was simply to add, in this branch, the update of
>>> the bind between "recycled" view and model item.
>>>
>>> HTH
>>> Sergio
>>>
>>>
>>>
>>> Il giorno giovedì 26 luglio 2012 12:59:05 UTC+2, Sergio Panico ha
>>> scritto:
>>>>
>>>> Hi all,
>>>> I need your help to understand the refresh behaviour of a ListView
>>>> where I've defined a my custom view for the ListView's items.
>>>>
>>>> I think It's better explain it with an example:
>>>> my adapter contains 7 items: A, B, C, D, E, F, G correctly initialized,
>>>> filled and working. The associated ListView shows 5 (out of 7) items: A, B,
>>>> C, D, E.
>>>> The problem is that, when I scroll down the ListView's content instead
>>>> of showing me items F and G, I've got A and B items again. I understood
>>>> that this is "only" a viewing issue becouse the model elements associated
>>>> with the last two items, correctly belong to F and G items. :|
>>>>
>>>> Following the ovveride of getView(...) method of my adapter (extending
>>>> BaseAdapter):
>>>>
>>>> @Override
>>>>     public View getView(int position, View convertView, ViewGroup
>>>> parent) {
>>>>         MyItemView miv = (( MyItemView  ) convertView);
>>>>
>>>>         if (context == null) return null;
>>>>
>>>>         if (convertView == null) {
>>>>             miv = new MyItemView (........);
>>>>             .....
>>>>         } else {
>>>>             miv.refreshView(); //refresh the view content
>>>>         }
>>>>
>>>>         return miv;
>>>>     }
>>>>
>>>> and the refreshView() method of MyItemView (extending LinearLayout):
>>>>
>>>> @Override
>>>>     public void refreshView() {
>>>>         label1.setText(......);
>>>>         label2.setText(......);
>>>>         label2.setText(......);
>>>>
>>>>         invalidate();
>>>>     }
>>>>
>>>> Thanks a lot to all!
>>>> Bye
>>>> Sergio
>>>>
>>>  --
>> 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
>>
>
>  --
> 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
>

-- 
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

Reply via email to