[android-developers] Re: What is wrong with Android Adapters?

2012-02-14 Thread jamesc
Hello

Are you using the ViewHolder pattern to recycle Views?

On Feb 13, 9:48 am, Olof Hedman  wrote:
> I have implemented a couple of different adapters in my application.
>
> No matter which base class I use, I get very weird behavior in how the
> list calls it to create and bind its views.
>
> I've tested this on 2.3.3, 2.3.6 and Kindle.
>
> This log is from an implementation of BaseAdapter, I put a debug-print
> in "getView".
> If convertView is null I inflate the view and print "created view".
> For every call to getView I print "binding View" when I set its
> values.
> The code on the end is an id string for the data I bind to the views.
>
> Everything display just as it should, but I get lots of unneccessary
> binds!
>
> This is what I get when I set the adapter to the listview:
>
> D/SLPA    ( 4097): created View - android.widget.LinearLayout@405bf190
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 0 - to: A5D7W5U9.02
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 1 - to: ASQK89Q8.58
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 2 - to: ASQK89Q8.37
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 3 - to: AEURWHRA.02
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 4 - to: ASQK89Q8.44
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 5 - to: ASQK89Q8.51
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 6 - to: ASQK89Q8.10
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 7 - to: AWQHVP6A.11
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 0 - to: A5D7W5U9.02
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 1 - to: ASQK89Q8.58
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 2 - to: ASQK89Q8.37
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 3 - to: AEURWHRA.02
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 4 - to: ASQK89Q8.44
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 5 - to: ASQK89Q8.51
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 6 - to: ASQK89Q8.10
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 7 - to: AWQHVP6A.11
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> position: 0 - to: A5D7W5U9.02
> D/SLPA    ( 4097): created View - android.widget.LinearLayout@405ab368
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405ab368
> position: 1 - to: ASQK89Q8.58
> D/SLPA    ( 4097): created View - android.widget.LinearLayout@405a85f8
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405a85f8
> position: 2 - to: ASQK89Q8.37
> D/SLPA    ( 4097): created View - android.widget.LinearLayout@40548088
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40548088
> position: 3 - to: AEURWHRA.02
> D/SLPA    ( 4097): created View - android.widget.LinearLayout@405743e0
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405743e0
> position: 4 - to: ASQK89Q8.44
> D/SLPA    ( 4097): created View - android.widget.LinearLayout@405877c0
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405877c0
> position: 5 - to: ASQK89Q8.51
>
> Its not weird that users complain of sluggish UI if these things are
> going on!
>
> When the device goes into sleep, I get this:
>
> D/SLPA    ( 4097): created View - android.widget.LinearLayout@40555a00
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 0 - to: A5D7W5U9.02
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 1 - to: ASQK89Q8.58
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 2 - to: ASQK89Q8.37
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 3 - to: AEURWHRA.02
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 4 - to: ASQK89Q8.44
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 5 - to: ASQK89Q8.51
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 6 - to: ASQK89Q8.10
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 0 - to: A5D7W5U9.02
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 1 - to: ASQK89Q8.58
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 2 - to: ASQK89Q8.37
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 3 - to: AEURWHRA.02
> D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> position: 4 

[android-developers] Re: What is wrong with Android Adapters?

2012-02-14 Thread jamesc
Also, are you calling notifyDatasetChanged() frequently?

On Feb 14, 9:10 am, jamesc  wrote:
> Hello
>
> Are you using the ViewHolder pattern to recycle Views?
>
> On Feb 13, 9:48 am, Olof Hedman  wrote:
>
>
>
>
>
>
>
> > I have implemented a couple of different adapters in my application.
>
> > No matter which base class I use, I get very weird behavior in how the
> > list calls it to create and bind its views.
>
> > I've tested this on 2.3.3, 2.3.6 and Kindle.
>
> > This log is from an implementation of BaseAdapter, I put a debug-print
> > in "getView".
> > If convertView is null I inflate the view and print "created view".
> > For every call to getView I print "binding View" when I set its
> > values.
> > The code on the end is an id string for the data I bind to the views.
>
> > Everything display just as it should, but I get lots of unneccessary
> > binds!
>
> > This is what I get when I set the adapter to the listview:
>
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405bf190
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 5 - to: ASQK89Q8.51
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 6 - to: ASQK89Q8.10
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 7 - to: AWQHVP6A.11
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 5 - to: ASQK89Q8.51
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 6 - to: ASQK89Q8.10
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 7 - to: AWQHVP6A.11
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405ab368
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405ab368
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405a85f8
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405a85f8
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@40548088
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40548088
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405743e0
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405743e0
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405877c0
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405877c0
> > position: 5 - to: ASQK89Q8.51
>
> > Its not weird that users complain of sluggish UI if these things are
> > going on!
>
> > When the device goes into sleep, I get this:
>
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@40555a00
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > position: 5 - to: ASQK89Q8.51
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > position: 6 - to: ASQK89Q8.10
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA  

[android-developers] Re: What is wrong with Android Adapters?

2012-02-14 Thread Doug
On Feb 13, 1:48 am, Olof Hedman  wrote:
> Is there anyone who can shed some light on this, is it just something
> I have to live with, or have I made some stupid mistake?
> I have a hard time imagining anything I could have done wrong though,
> since the code is really minimal.

Why aren't you showing your code, since it is so minimal?  Your log
isn't helping anyone understand what you actually did.  BTW, "minimal"
doesn't equate to "correct".

If anything at all is invalidating views in your list, it may be
getting rebuilt.  If your adapter is getting refreshed somehow, it may
be getting rebuilt.

You could also try starting with a sample from ApiDemos and building
from there.

Doug

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Olof Hedman
Thanks for replying!
I seem to have some problem replying in this thread.
My messages never show up?

Lets hope this one works...

I think this example is the best, it shows the exact same pattern in
the calls to getView, its a completely static list with no refreshing
at all going on:

http://pastebin.com/M8QcQu21

It's using a ListAdapter as base class, because at that point I had
overlooked BaseListAdapter, but that shouldn't really matter...

Cheers,
Olof

On Feb 15, 12:43 am, Doug  wrote:
> On Feb 13, 1:48 am, Olof Hedman  wrote:
>
> > Is there anyone who can shed some light on this, is it just something
> > I have to live with, or have I made some stupid mistake?
> > I have a hard time imagining anything I could have done wrong though,
> > since the code is really minimal.
>
> Why aren't you showing your code, since it is so minimal?  Your log
> isn't helping anyone understand what you actually did.  BTW, "minimal"
> doesn't equate to "correct".
>
> If anything at all is invalidating views in your list, it may be
> getting rebuilt.  If your adapter is getting refreshed somehow, it may
> be getting rebuilt.
>
> You could also try starting with a sample from ApiDemos and building
> from there.
>
> Doug

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Olof Hedman
Great, it works :)

In another lost message, I said that there is no invalidating going on
at these points.
The most curious of them all is that 3x refreshing of all views on
power-down.
Absolutely no implementation at all in onPause in the activity.

ViewHolder pattern will not help me, since that only means caching of
the findViewById calls.
But I thank you for that tip anyhow, since it should lessen the
impact.

But to me it still seems android lists are slightly broken, at least
in 2.3...
Havn't had the opportunity to try other versions yet.

Are there really no-one else who have noticed this behaviour?

Cheers,
Olof

On Feb 15, 10:03 am, Olof Hedman  wrote:
> Thanks for replying!
> I seem to have some problem replying in this thread.
> My messages never show up?
>
> Lets hope this one works...
>
> I think this example is the best, it shows the exact same pattern in
> the calls to getView, its a completely static list with no refreshing
> at all going on:
>
> http://pastebin.com/M8QcQu21
>
> It's using a ListAdapter as base class, because at that point I had
> overlooked BaseListAdapter, but that shouldn't really matter...
>
> Cheers,
> Olof
>
> On Feb 15, 12:43 am, Doug  wrote:
>
>
>
>
>
>
>
> > On Feb 13, 1:48 am, Olof Hedman  wrote:
>
> > > Is there anyone who can shed some light on this, is it just something
> > > I have to live with, or have I made some stupid mistake?
> > > I have a hard time imagining anything I could have done wrong though,
> > > since the code is really minimal.
>
> > Why aren't you showing your code, since it is so minimal?  Your log
> > isn't helping anyone understand what you actually did.  BTW, "minimal"
> > doesn't equate to "correct".
>
> > If anything at all is invalidating views in your list, it may be
> > getting rebuilt.  If your adapter is getting refreshed somehow, it may
> > be getting rebuilt.
>
> > You could also try starting with a sample from ApiDemos and building
> > from there.
>
> > Doug

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Olof Hedman
I've got 7 different adapters in my application, and they all look
like they work perfectly, but they all show this weird pattern in the
calls to getView.

Look closer on the logs, I think they say a lot actually.
Notice when views are created, and how they are bound, and try explain
the logic behind that...

I have a lot of experience in mobile UI frameworks, I've even worked
for the top manufacturers for about 5 years with optimizing and
animating their UI frameworks, before they got obsolete by Android :)
I know list-frameworks are a lot trickier then you might think to get
right, so I'm not super surprised if someone messed up somewhere in
the framework...

Cheers,
Olof


On Feb 15, 10:17 am, Olof Hedman  wrote:
> Great, it works :)
>
> In another lost message, I said that there is no invalidating going on
> at these points.
> The most curious of them all is that 3x refreshing of all views on
> power-down.
> Absolutely no implementation at all in onPause in the activity.
>
> ViewHolder pattern will not help me, since that only means caching of
> the findViewById calls.
> But I thank you for that tip anyhow, since it should lessen the
> impact.
>
> But to me it still seems android lists are slightly broken, at least
> in 2.3...
> Havn't had the opportunity to try other versions yet.
>
> Are there really no-one else who have noticed this behaviour?
>
> Cheers,
> Olof
>
> On Feb 15, 10:03 am, Olof Hedman  wrote:
>
>
>
>
>
>
>
> > Thanks for replying!
> > I seem to have some problem replying in this thread.
> > My messages never show up?
>
> > Lets hope this one works...
>
> > I think this example is the best, it shows the exact same pattern in
> > the calls to getView, its a completely static list with no refreshing
> > at all going on:
>
> >http://pastebin.com/M8QcQu21
>
> > It's using a ListAdapter as base class, because at that point I had
> > overlooked BaseListAdapter, but that shouldn't really matter...
>
> > Cheers,
> > Olof
>
> > On Feb 15, 12:43 am, Doug  wrote:
>
> > > On Feb 13, 1:48 am, Olof Hedman  wrote:
>
> > > > Is there anyone who can shed some light on this, is it just something
> > > > I have to live with, or have I made some stupid mistake?
> > > > I have a hard time imagining anything I could have done wrong though,
> > > > since the code is really minimal.
>
> > > Why aren't you showing your code, since it is so minimal?  Your log
> > > isn't helping anyone understand what you actually did.  BTW, "minimal"
> > > doesn't equate to "correct".
>
> > > If anything at all is invalidating views in your list, it may be
> > > getting rebuilt.  If your adapter is getting refreshed somehow, it may
> > > be getting rebuilt.
>
> > > You could also try starting with a sample from ApiDemos and building
> > > from there.
>
> > > Doug

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread alh
Hi,

Thank you for answering.
I wanted to keep the post brief until I found someone interested.

I've got code for another adapter implementation on stackoverflow,
which show the exact same pattern in the calls to getView.
Though this is a CursorTreeAdapter, so it calls "newView" and
"bindView" for me in its implementation of "getView"
http://stackoverflow.com/questions/9250781/cursortreeadapter-binding-views-excessivly-very-weird-behaviour

Any adapter I implement have the same pattern in how getView is
called.
They all look like they work perfectly, until you look closer on how
the methods are called.

Specially the 3x rebinding of all views when I enter powerdown is very
curious.
(There is nothing done in onPause that should affect the list)

Here is a third adapter that also show the exact same pattern, and is
the most minmal I have:
http://pastebin.com/hutfJPcN

It implements ListAdapter, because at that point I had overlooked
BaseListAdapter, but it shouldn't matter.

Cheer,
Olof

On Feb 15, 12:43 am, Doug  wrote:
> On Feb 13, 1:48 am, Olof Hedman  wrote:
>
> > Is there anyone who can shed some light on this, is it just something
> > I have to live with, or have I made some stupid mistake?
> > I have a hard time imagining anything I could have done wrong though,
> > since the code is really minimal.
>
> Why aren't you showing your code, since it is so minimal?  Your log
> isn't helping anyone understand what you actually did.  BTW, "minimal"
> doesn't equate to "correct".
>
> If anything at all is invalidating views in your list, it may be
> getting rebuilt.  If your adapter is getting refreshed somehow, it may
> be getting rebuilt.
>
> You could also try starting with a sample from ApiDemos and building
> from there.
>
> Doug

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread alh
Views are recycled, though I do not cache findViewById-calls at the
moment (as with the ViewHolder pattern)
I don't think that should affect how many calls I get to "getView"...
thanks for the tip though, it should lessen the impact a bit.
But android still seems a bit broken in this detail...

There are no extra calls to notifyDatasetChanged.

Cheers,
Olof

On Feb 14, 10:10 am, jamesc  wrote:
> Hello
>
> Are you using the ViewHolder pattern to recycle Views?
>
> On Feb 13, 9:48 am, Olof Hedman  wrote:
>
>
>
>
>
>
>
> > I have implemented a couple of differentadaptersin my application.
>
> > No matter which base class I use, I get very weird behavior in how the
> > list calls it to create and bind its views.
>
> > I've tested this on 2.3.3, 2.3.6 and Kindle.
>
> > This log is from an implementation of BaseAdapter, I put a debug-print
> > in "getView".
> > If convertView is null I inflate the view and print "created view".
> > For every call to getView I print "binding View" when I set its
> > values.
> > The code on the end is an id string for the data I bind to the views.
>
> > Everything display just as it should, but I get lots of unneccessary
> > binds!
>
> > This is what I get when I set the adapter to the listview:
>
> > D/SLPA    ( 4097): created View -android.widget.LinearLayout@405bf190
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 5 - to: ASQK89Q8.51
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 6 - to: ASQK89Q8.10
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 7 - to: AWQHVP6A.11
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 5 - to: ASQK89Q8.51
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 6 - to: ASQK89Q8.10
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 7 - to: AWQHVP6A.11
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405bf190
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): created View -android.widget.LinearLayout@405ab368
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405ab368
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): created View -android.widget.LinearLayout@405a85f8
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405a85f8
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): created View -android.widget.LinearLayout@40548088
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@40548088
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): created View -android.widget.LinearLayout@405743e0
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405743e0
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): created View -android.widget.LinearLayout@405877c0
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@405877c0
> > position: 5 - to: ASQK89Q8.51
>
> > Its not weird that users complain of sluggish UI if these things are
> > going on!
>
> > When the device goes into sleep, I get this:
>
> > D/SLPA    ( 4097): created View -android.widget.LinearLayout@40555a00
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@40555a00
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@40555a00
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@40555a00
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@40555a00
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@40555a00
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@40555a00
> > position: 5 - to: ASQK89Q8.51
> > D/SLPA    ( 4097): binding View -android.widget.LinearLayout@40555a0

[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread gropapa
did you use addHeaderView() in your code?

On 14 fév, 10:22, jamesc  wrote:
> Also, are you calling notifyDatasetChanged() frequently?
>
> On Feb 14, 9:10 am, jamesc  wrote:
>
>
>
>
>
>
>
> > Hello
>
> > Are you using the ViewHolder pattern to recycle Views?
>
> > On Feb 13, 9:48 am, Olof Hedman  wrote:
>
> > > I have implemented a couple of different adapters in my application.
>
> > > No matter which base class I use, I get very weird behavior in how the
> > > list calls it to create and bind its views.
>
> > > I've tested this on 2.3.3, 2.3.6 and Kindle.
>
> > > This log is from an implementation of BaseAdapter, I put a debug-print
> > > in "getView".
> > > If convertView is null I inflate the view and print "created view".
> > > For every call to getView I print "binding View" when I set its
> > > values.
> > > The code on the end is an id string for the data I bind to the views.
>
> > > Everything display just as it should, but I get lots of unneccessary
> > > binds!
>
> > > This is what I get when I set the adapter to the listview:
>
> > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405bf190
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 0 - to: A5D7W5U9.02
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 1 - to: ASQK89Q8.58
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 2 - to: ASQK89Q8.37
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 3 - to: AEURWHRA.02
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 4 - to: ASQK89Q8.44
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 5 - to: ASQK89Q8.51
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 6 - to: ASQK89Q8.10
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 7 - to: AWQHVP6A.11
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 0 - to: A5D7W5U9.02
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 1 - to: ASQK89Q8.58
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 2 - to: ASQK89Q8.37
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 3 - to: AEURWHRA.02
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 4 - to: ASQK89Q8.44
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 5 - to: ASQK89Q8.51
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 6 - to: ASQK89Q8.10
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 7 - to: AWQHVP6A.11
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > position: 0 - to: A5D7W5U9.02
> > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405ab368
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405ab368
> > > position: 1 - to: ASQK89Q8.58
> > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405a85f8
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405a85f8
> > > position: 2 - to: ASQK89Q8.37
> > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@40548088
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40548088
> > > position: 3 - to: AEURWHRA.02
> > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405743e0
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405743e0
> > > position: 4 - to: ASQK89Q8.44
> > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405877c0
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405877c0
> > > position: 5 - to: ASQK89Q8.51
>
> > > Its not weird that users complain of sluggish UI if these things are
> > > going on!
>
> > > When the device goes into sleep, I get this:
>
> > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@40555a00
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > position: 0 - to: A5D7W5U9.02
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > position: 1 - to: ASQK89Q8.58
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > position: 2 - to: ASQK89Q8.37
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > position: 3 - to: AEURWHRA.02
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > position: 4 - to: ASQK89Q8.44
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > position: 5 - to: ASQK89Q8.51
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > position:

[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Olof Hedman
I did not. I have no need for headers in my lists.
Why do you ask?

Cheers,
Olof

On Feb 14, 12:38 pm, gropapa  wrote:
> did you use addHeaderView() in your code?
>
> On 14 fév, 10:22, jamesc  wrote:
>
>
>
>
>
>
>
> > Also, are you calling notifyDatasetChanged() frequently?
>
> > On Feb 14, 9:10 am, jamesc  wrote:
>
> > > Hello
>
> > > Are you using the ViewHolder pattern to recycle Views?
>
> > > On Feb 13, 9:48 am, Olof Hedman  wrote:
>
> > > > I have implemented a couple of different adapters in my application.
>
> > > > No matter which base class I use, I get very weird behavior in how the
> > > > list calls it to create and bind its views.
>
> > > > I've tested this on 2.3.3, 2.3.6 and Kindle.
>
> > > > This log is from an implementation of BaseAdapter, I put a debug-print
> > > > in "getView".
> > > > If convertView is null I inflate the view and print "created view".
> > > > For every call to getView I print "binding View" when I set its
> > > > values.
> > > > The code on the end is an id string for the data I bind to the views.
>
> > > > Everything display just as it should, but I get lots of unneccessary
> > > > binds!
>
> > > > This is what I get when I set the adapter to the listview:
>
> > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405bf190
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 0 - to: A5D7W5U9.02
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 1 - to: ASQK89Q8.58
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 2 - to: ASQK89Q8.37
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 3 - to: AEURWHRA.02
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 4 - to: ASQK89Q8.44
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 5 - to: ASQK89Q8.51
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 6 - to: ASQK89Q8.10
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 7 - to: AWQHVP6A.11
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 0 - to: A5D7W5U9.02
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 1 - to: ASQK89Q8.58
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 2 - to: ASQK89Q8.37
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 3 - to: AEURWHRA.02
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 4 - to: ASQK89Q8.44
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 5 - to: ASQK89Q8.51
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 6 - to: ASQK89Q8.10
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 7 - to: AWQHVP6A.11
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > position: 0 - to: A5D7W5U9.02
> > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405ab368
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405ab368
> > > > position: 1 - to: ASQK89Q8.58
> > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405a85f8
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405a85f8
> > > > position: 2 - to: ASQK89Q8.37
> > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@40548088
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40548088
> > > > position: 3 - to: AEURWHRA.02
> > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405743e0
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405743e0
> > > > position: 4 - to: ASQK89Q8.44
> > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405877c0
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405877c0
> > > > position: 5 - to: ASQK89Q8.51
>
> > > > Its not weird that users complain of sluggish UI if these things are
> > > > going on!
>
> > > > When the device goes into sleep, I get this:
>
> > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@40555a00
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > > position: 0 - to: A5D7W5U9.02
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > > position: 1 - to: ASQK89Q8.58
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > > position: 2 - to: ASQK89Q8.37
> > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > > position: 3 - to: AEURWHRA.02
> > > > D/SLPA    ( 4097): bindi

[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Olof Hedman
I don't expect it to.
But I do though expect it to call it a sensible amount of times, and
not call it when it is absolutely unnecessary.
Why would it for example have to bind all my list items to the first
view two times over, before creating the other list item views?

Cheers,
Olof

On Feb 15, 2:02 pm, Kostya Vasilyev  wrote:
> AdapterView does not make any guarantees about when and how many times
> the adapter's getView is called.
>
> -- Kostya
>
> 15.02.2012 15:35, Olof Hedman пишет:
>
>
>
>
>
>
>
>
>
> > I did not. I have no need for headers in my lists.
> > Why do you ask?
>
> > Cheers,
> > Olof
>
> > On Feb 14, 12:38 pm, gropapa  wrote:
> >> did you use addHeaderView() in your code?
>
> >> On 14 fév, 10:22, jamesc  wrote:
>
> >>> Also, are you calling notifyDatasetChanged() frequently?
> >>> On Feb 14, 9:10 am, jamesc  wrote:
>  Hello
>  Are you using the ViewHolder pattern to recycle Views?
>  On Feb 13, 9:48 am, Olof Hedman  wrote:
> > I have implemented a couple of different adapters in my application.
> > No matter which base class I use, I get very weird behavior in how the
> > list calls it to create and bind its views.
> > I've tested this on 2.3.3, 2.3.6 and Kindle.
> > This log is from an implementation of BaseAdapter, I put a debug-print
> > in "getView".
> > If convertView is null I inflate the view and print "created view".
> > For every call to getView I print "binding View" when I set its
> > values.
> > The code on the end is an id string for the data I bind to the views.
> > Everything display just as it should, but I get lots of unneccessary
> > binds!
> > This is what I get when I set the adapter to the listview:
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405bf190
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 5 - to: ASQK89Q8.51
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 6 - to: ASQK89Q8.10
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 7 - to: AWQHVP6A.11
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 5 - to: ASQK89Q8.51
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 6 - to: ASQK89Q8.10
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 7 - to: AWQHVP6A.11
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > position: 0 - to: A5D7W5U9.02
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405ab368
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405ab368
> > position: 1 - to: ASQK89Q8.58
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405a85f8
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405a85f8
> > position: 2 - to: ASQK89Q8.37
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@40548088
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40548088
> > position: 3 - to: AEURWHRA.02
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405743e0
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405743e0
> > position: 4 - to: ASQK89Q8.44
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405877c0
> > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405877c0
> > position: 5 - to: ASQK89Q8.51
> > Its not weird that users complain of sluggish UI if these things are
> > going on!
> > When the device goes into sleep, I get this:
> > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405

[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Olof Hedman


On Feb 15, 2:57 pm, Kostya Vasilyev  wrote:
> On 02/15/2012 05:37 PM, Olof Hedman wrote:
>
> > I don't expect it to.
> > But I do though expect it to call it a sensible amount of times, and
> > not call it when it is absolutely unnecessary.
>
> That may not be the ListView's definition of "sensible".
>

I don't think you look closely enough on what is happening here

> > Why would it for example have to bind all my list items to the first
> > view two times over, before creating the other list item views?
>
> Perhaps it's populating a cache of some kind?
>

That theory doesn't hold.
It would only need to cache the views once, and if you look at what is
actually happening, you will se it binds the _same_view_ over and over
with different list item data.
Nothing is then cached, for a list with 8 items, the information will
be overwritten 16 times before it settles and start to create more
views for the list.
I can't see any reason to bind all list items 2 times over to the
first view before creating the next view in the list.

>
>
>
>
> > Cheers,
> > Olof

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Olof Hedman
Thanks for the log!
Which version of android did you run it on?

It made my try one more thing...
I simplified my layout as much as I could, and this actually got rid
of the extreme weirdness, and made my log look like yours.

I don't get though why it would matter.
The problem seem to be the relative-layout I have in the background.
(I use it for a background image + a logo shown behind the list)

Here is my layout with just the relative-layout commented out:
http://pastebin.com/zFBxL97m

The view never resizes or anything, so there seems to be some funky-
ness going on when it inflates the views for the Activity.
Do you have any idea of why it would behave like this because of the
relativelayout?

Also still weird it thinks its necessary to re-getting the views when
the screen power down, but at least the user will only notice that
because of slightly worse battery life :)

Cheers,
Olof


On Feb 15, 5:28 pm, Kostya Vasilyev  wrote:
> On 02/15/2012 08:02 PM, Olof Hedman wrote:
>
> >> Perhaps it's populating a cache of some kind?
>
> > That theory doesn't hold.
> > It would only need to cache the views once, and if you look at what is
> > actually happening, you will se it binds the_same_view_  over and over
> > with different list item data.
> > Nothing is then cached, for a list with 8 items, the information will
> > be overwritten 16 times before it settles and start to create more
> > views for the list.
>
> I just happened to have an app with ListView handy, so, here is my log,
> the number is the position passed into getView, the reference is the
> convertView:
>
> When the activity is shown for the first time:
>
> 02-15 20:17:45.058 I/ScanViewModeList(11347): getView for 0, null
> 02-15 20:17:45.097 I/ScanViewModeList(11347): getView for 1, null
> 02-15 20:17:45.160 I/ScanViewModeList(11347): getView for 2, null
> 02-15 20:17:45.238 I/ScanViewModeList(11347): getView for 0,
> android.widget.LinearLayout@41877ac8
> 02-15 20:17:45.238 I/ScanViewModeList(11347): getView for 1,
> android.widget.LinearLayout@418c4fe8
> 02-15 20:17:45.238 I/ScanViewModeList(11347): getView for 2,
> android.widget.LinearLayout@41879f70
>
> After the list is invalidated:
>
> 02-15 20:17:47.832 I/ScanViewModeList(11347): getView for 0,
> android.widget.LinearLayout@41877ac8
> 02-15 20:17:47.840 I/ScanViewModeList(11347): getView for 1,
> android.widget.LinearLayout@418c4fe8
> 02-15 20:17:47.847 I/ScanViewModeList(11347): getView for 2,
> android.widget.LinearLayout@41879f70
>
> The initial calls to getView with null are, perhaps, unnecessary, but
> could be legit. In any case, they only happen once, when the listview is
> initally shown.
>
> As for your log - does your code do anything that could cause listview
> to change its size, and force a new layout pass? does it unnecessarily
> call adapter.notifyDataSet{Changed|Invalidated}?
>
> -- Kostya

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Olof Hedman
Hmm, hold that...
Might have made a mistake in my tests...
I'll revisit this tomorrow when my brain works better :)

Cheers,
Olof

On Feb 15, 7:45 pm, Olof Hedman  wrote:
> Thanks for the log!
> Which version of android did you run it on?
>
> It made my try one more thing...
> I simplified my layout as much as I could, and this actually got rid
> of the extreme weirdness, and made my log look like yours.
>
> I don't get though why it would matter.
> The problem seem to be the relative-layout I have in the background.
> (I use it for a background image + a logo shown behind the list)
>
> Here is my layout with just the relative-layout commented 
> out:http://pastebin.com/zFBxL97m
>
> The view never resizes or anything, so there seems to be some funky-
> ness going on when it inflates the views for the Activity.
> Do you have any idea of why it would behave like this because of the
> relativelayout?
>
> Also still weird it thinks its necessary to re-getting the views when
> the screen power down, but at least the user will only notice that
> because of slightly worse battery life :)
>
> Cheers,
> Olof
>
> On Feb 15, 5:28 pm, Kostya Vasilyev  wrote:
>
>
>
>
>
>
>
> > On 02/15/2012 08:02 PM, Olof Hedman wrote:
>
> > >> Perhaps it's populating a cache of some kind?
>
> > > That theory doesn't hold.
> > > It would only need to cache the views once, and if you look at what is
> > > actually happening, you will se it binds the_same_view_  over and over
> > > with different list item data.
> > > Nothing is then cached, for a list with 8 items, the information will
> > > be overwritten 16 times before it settles and start to create more
> > > views for the list.
>
> > I just happened to have an app with ListView handy, so, here is my log,
> > the number is the position passed into getView, the reference is the
> > convertView:
>
> > When the activity is shown for the first time:
>
> > 02-15 20:17:45.058 I/ScanViewModeList(11347): getView for 0, null
> > 02-15 20:17:45.097 I/ScanViewModeList(11347): getView for 1, null
> > 02-15 20:17:45.160 I/ScanViewModeList(11347): getView for 2, null
> > 02-15 20:17:45.238 I/ScanViewModeList(11347): getView for 0,
> > android.widget.LinearLayout@41877ac8
> > 02-15 20:17:45.238 I/ScanViewModeList(11347): getView for 1,
> > android.widget.LinearLayout@418c4fe8
> > 02-15 20:17:45.238 I/ScanViewModeList(11347): getView for 2,
> > android.widget.LinearLayout@41879f70
>
> > After the list is invalidated:
>
> > 02-15 20:17:47.832 I/ScanViewModeList(11347): getView for 0,
> > android.widget.LinearLayout@41877ac8
> > 02-15 20:17:47.840 I/ScanViewModeList(11347): getView for 1,
> > android.widget.LinearLayout@418c4fe8
> > 02-15 20:17:47.847 I/ScanViewModeList(11347): getView for 2,
> > android.widget.LinearLayout@41879f70
>
> > The initial calls to getView with null are, perhaps, unnecessary, but
> > could be legit. In any case, they only happen once, when the listview is
> > initally shown.
>
> > As for your log - does your code do anything that could cause listview
> > to change its size, and force a new layout pass? does it unnecessarily
> > call adapter.notifyDataSet{Changed|Invalidated}?
>
> > -- Kostya

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Olof Hedman
Turns out my super-simple adapter never had the on init-problem.
But it still has the on power down-problem.
Its a 100% static list with the views created on startup and put into
an array.
Wait a while after the power turns off and check your logs, I'm pretty
sure you will se a couple of "getView":s in your logs too.
It doesn't come right away, but within a minute or so after the screen
goes black.

I'll revisit my slightly more complex adapters tomorrow.

Cheers,
Olof


On Feb 15, 7:58 pm, Kostya Vasilyev  wrote:
> On 02/15/2012 10:45 PM, Olof Hedman wrote:
>
> > Thanks for the log!
> > Which version of android did you run it on?
>
> 2.3.4 and 4.0.2
>
> > It made my try one more thing...
> > I simplified my layout as much as I could, and this actually got rid
> > of the extreme weirdness, and made my log look like yours.
>
> > I don't get though why it would matter.
> > The problem seem to be the relative-layout I have in the background.
> > (I use it for a background image + a logo shown behind the list)
>
> > Here is my layout with just the relative-layout commented out:
> >http://pastebin.com/zFBxL97m
>
> > The view never resizes or anything, so there seems to be some funky-
> > ness going on when it inflates the views for the Activity.
> > Do you have any idea of why it would behave like this because of the
> > relativelayout?
>
> If you wanted to investigate, I suppose you could make your own subclass
> of ListView, override requestLayout and put a log statement there.
>
>
>
> > Also still weird it thinks its necessary to re-getting the views when
> > the screen power down, but at least the user will only notice that
> > because of slightly worse battery life:)
>
> By itself, the backlight turning off does not have anything to do with it.
>
> However, take a look at your activty's onResume to see if it tells the
> view to invalidate.
>
> If your list view is backed by a managed cursor, the latter will be
> requiried around the time of onResume, in turn causing the list view to
> fully update.
>
> -- Kostya
>
>
>
>
>
>
>
>
>
> > Cheers,
> > Olof

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread gropapa
because using the addHeaderView() forces the use of another type of
adapter...stupid things in android



On 15 fév, 12:35, Olof Hedman  wrote:
> I did not. I have no need for headers in my lists.
> Why do you ask?
>
> Cheers,
> Olof
>
> On Feb 14, 12:38 pm, gropapa  wrote:
>
>
>
>
>
>
>
> > did you use addHeaderView() in your code?
>
> > On 14 fév, 10:22, jamesc  wrote:
>
> > > Also, are you calling notifyDatasetChanged() frequently?
>
> > > On Feb 14, 9:10 am, jamesc  wrote:
>
> > > > Hello
>
> > > > Are you using the ViewHolder pattern to recycle Views?
>
> > > > On Feb 13, 9:48 am, Olof Hedman  wrote:
>
> > > > > I have implemented a couple of different adapters in my application.
>
> > > > > No matter which base class I use, I get very weird behavior in how the
> > > > > list calls it to create and bind its views.
>
> > > > > I've tested this on 2.3.3, 2.3.6 and Kindle.
>
> > > > > This log is from an implementation of BaseAdapter, I put a debug-print
> > > > > in "getView".
> > > > > If convertView is null I inflate the view and print "created view".
> > > > > For every call to getView I print "binding View" when I set its
> > > > > values.
> > > > > The code on the end is an id string for the data I bind to the views.
>
> > > > > Everything display just as it should, but I get lots of unneccessary
> > > > > binds!
>
> > > > > This is what I get when I set the adapter to the listview:
>
> > > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405bf190
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 0 - to: A5D7W5U9.02
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 1 - to: ASQK89Q8.58
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 2 - to: ASQK89Q8.37
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 3 - to: AEURWHRA.02
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 4 - to: ASQK89Q8.44
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 5 - to: ASQK89Q8.51
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 6 - to: ASQK89Q8.10
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 7 - to: AWQHVP6A.11
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 0 - to: A5D7W5U9.02
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 1 - to: ASQK89Q8.58
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 2 - to: ASQK89Q8.37
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 3 - to: AEURWHRA.02
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 4 - to: ASQK89Q8.44
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 5 - to: ASQK89Q8.51
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 6 - to: ASQK89Q8.10
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 7 - to: AWQHVP6A.11
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405bf190
> > > > > position: 0 - to: A5D7W5U9.02
> > > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405ab368
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405ab368
> > > > > position: 1 - to: ASQK89Q8.58
> > > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405a85f8
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405a85f8
> > > > > position: 2 - to: ASQK89Q8.37
> > > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@40548088
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40548088
> > > > > position: 3 - to: AEURWHRA.02
> > > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405743e0
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405743e0
> > > > > position: 4 - to: ASQK89Q8.44
> > > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@405877c0
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405877c0
> > > > > position: 5 - to: ASQK89Q8.51
>
> > > > > Its not weird that users complain of sluggish UI if these things are
> > > > > going on!
>
> > > > > When the device goes into sleep, I get this:
>
> > > > > D/SLPA    ( 4097): created View - android.widget.LinearLayout@40555a00
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40555a00
> > > > > position: 0 - to: A5D7W5U9.02
> > > > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@4

[android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread alh
On Feb 15, 8:24 pm, Kostya Vasilyev  wrote:
> I took a break for over 10 minutes, leaving logcat running, and...
> sorry, it just doesn't.

Very interesting :)
Thanks for trying it

Cheers,
Olof

-- 
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Kostya Vasilyev
AdapterView does not make any guarantees about when and how many times 
the adapter's getView is called.


-- Kostya

15.02.2012 15:35, Olof Hedman пишет:

I did not. I have no need for headers in my lists.
Why do you ask?

Cheers,
Olof

On Feb 14, 12:38 pm, gropapa  wrote:

did you use addHeaderView() in your code?

On 14 fév, 10:22, jamesc  wrote:








Also, are you calling notifyDatasetChanged() frequently?
On Feb 14, 9:10 am, jamesc  wrote:

Hello
Are you using the ViewHolder pattern to recycle Views?
On Feb 13, 9:48 am, Olof Hedman  wrote:

I have implemented a couple of different adapters in my application.
No matter which base class I use, I get very weird behavior in how the
list calls it to create and bind its views.
I've tested this on 2.3.3, 2.3.6 and Kindle.
This log is from an implementation of BaseAdapter, I put a debug-print
in "getView".
If convertView is null I inflate the view and print "created view".
For every call to getView I print "binding View" when I set its
values.
The code on the end is an id string for the data I bind to the views.
Everything display just as it should, but I get lots of unneccessary
binds!
This is what I get when I set the adapter to the listview:
D/SLPA( 4097): created View - android.widget.LinearLayout@405bf190
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 0 - to: A5D7W5U9.02
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 1 - to: ASQK89Q8.58
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 2 - to: ASQK89Q8.37
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 3 - to: AEURWHRA.02
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 4 - to: ASQK89Q8.44
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 5 - to: ASQK89Q8.51
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 6 - to: ASQK89Q8.10
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 7 - to: AWQHVP6A.11
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 0 - to: A5D7W5U9.02
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 1 - to: ASQK89Q8.58
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 2 - to: ASQK89Q8.37
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 3 - to: AEURWHRA.02
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 4 - to: ASQK89Q8.44
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 5 - to: ASQK89Q8.51
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 6 - to: ASQK89Q8.10
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 7 - to: AWQHVP6A.11
D/SLPA( 4097): binding View - android.widget.LinearLayout@405bf190
position: 0 - to: A5D7W5U9.02
D/SLPA( 4097): created View - android.widget.LinearLayout@405ab368
D/SLPA( 4097): binding View - android.widget.LinearLayout@405ab368
position: 1 - to: ASQK89Q8.58
D/SLPA( 4097): created View - android.widget.LinearLayout@405a85f8
D/SLPA( 4097): binding View - android.widget.LinearLayout@405a85f8
position: 2 - to: ASQK89Q8.37
D/SLPA( 4097): created View - android.widget.LinearLayout@40548088
D/SLPA( 4097): binding View - android.widget.LinearLayout@40548088
position: 3 - to: AEURWHRA.02
D/SLPA( 4097): created View - android.widget.LinearLayout@405743e0
D/SLPA( 4097): binding View - android.widget.LinearLayout@405743e0
position: 4 - to: ASQK89Q8.44
D/SLPA( 4097): created View - android.widget.LinearLayout@405877c0
D/SLPA( 4097): binding View - android.widget.LinearLayout@405877c0
position: 5 - to: ASQK89Q8.51
Its not weird that users complain of sluggish UI if these things are
going on!
When the device goes into sleep, I get this:
D/SLPA( 4097): created View - android.widget.LinearLayout@40555a00
D/SLPA( 4097): binding View - android.widget.LinearLayout@40555a00
position: 0 - to: A5D7W5U9.02
D/SLPA( 4097): binding View - android.widget.LinearLayout@40555a00
position: 1 - to: ASQK89Q8.58
D/SLPA( 4097): binding View - android.widget.LinearLayout@40555a00
position: 2 - to: ASQK89Q8.37
D/SLPA( 4097): binding View - android.widget.LinearLayout@40555a00
position: 3 - to: AEURWHRA.02
D/SLPA( 4097): binding View - android.widget.LinearLayout@40555a00
position: 4 - to: ASQK89Q8.44
D/SLPA( 4097): binding View - android.widget.LinearLayout@40555a00
position: 5 - to: ASQK89Q8.51
D/SLPA( 4097): binding View - android.widget.LinearLayout@40555a00
position: 6 - to: ASQK89Q8.10
D/SLPA( 4097): binding View - android.widget.LinearLayout@40555a00
position: 0 - to: A5D7W5U9.02
D/SLPA( 4097): binding View - android.widget.LinearLayout@40555a00
position: 1 - to: ASQK89Q8.58
D/SLPA( 4097): binding View -

Re: [android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Kostya Vasilyev

On 02/15/2012 05:37 PM, Olof Hedman wrote:

I don't expect it to.
But I do though expect it to call it a sensible amount of times, and
not call it when it is absolutely unnecessary.


That may not be the ListView's definition of "sensible".


Why would it for example have to bind all my list items to the first
view two times over, before creating the other list item views?


Perhaps it's populating a cache of some kind?




Cheers,
Olof


--
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Kostya Vasilyev

On 02/15/2012 08:02 PM, Olof Hedman wrote:

Perhaps it's populating a cache of some kind?
>

That theory doesn't hold.
It would only need to cache the views once, and if you look at what is
actually happening, you will se it binds the_same_view_  over and over
with different list item data.
Nothing is then cached, for a list with 8 items, the information will
be overwritten 16 times before it settles and start to create more
views for the list.


I just happened to have an app with ListView handy, so, here is my log, 
the number is the position passed into getView, the reference is the 
convertView:


When the activity is shown for the first time:

02-15 20:17:45.058 I/ScanViewModeList(11347): getView for 0, null
02-15 20:17:45.097 I/ScanViewModeList(11347): getView for 1, null
02-15 20:17:45.160 I/ScanViewModeList(11347): getView for 2, null
02-15 20:17:45.238 I/ScanViewModeList(11347): getView for 0, 
android.widget.LinearLayout@41877ac8
02-15 20:17:45.238 I/ScanViewModeList(11347): getView for 1, 
android.widget.LinearLayout@418c4fe8
02-15 20:17:45.238 I/ScanViewModeList(11347): getView for 2, 
android.widget.LinearLayout@41879f70


After the list is invalidated:

02-15 20:17:47.832 I/ScanViewModeList(11347): getView for 0, 
android.widget.LinearLayout@41877ac8
02-15 20:17:47.840 I/ScanViewModeList(11347): getView for 1, 
android.widget.LinearLayout@418c4fe8
02-15 20:17:47.847 I/ScanViewModeList(11347): getView for 2, 
android.widget.LinearLayout@41879f70


The initial calls to getView with null are, perhaps, unnecessary, but 
could be legit. In any case, they only happen once, when the listview is 
initally shown.


As for your log - does your code do anything that could cause listview 
to change its size, and force a new layout pass? does it unnecessarily 
call adapter.notifyDataSet{Changed|Invalidated}?


-- Kostya

--
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Kostya Vasilyev

On 02/15/2012 10:45 PM, Olof Hedman wrote:

Thanks for the log!
Which version of android did you run it on?


2.3.4 and 4.0.2


It made my try one more thing...
I simplified my layout as much as I could, and this actually got rid
of the extreme weirdness, and made my log look like yours.

I don't get though why it would matter.
The problem seem to be the relative-layout I have in the background.
(I use it for a background image + a logo shown behind the list)

Here is my layout with just the relative-layout commented out:
http://pastebin.com/zFBxL97m

The view never resizes or anything, so there seems to be some funky-
ness going on when it inflates the views for the Activity.
Do you have any idea of why it would behave like this because of the
relativelayout?


If you wanted to investigate, I suppose you could make your own subclass 
of ListView, override requestLayout and put a log statement there.




Also still weird it thinks its necessary to re-getting the views when
the screen power down, but at least the user will only notice that
because of slightly worse battery life:)


By itself, the backlight turning off does not have anything to do with it.

However, take a look at your activty's onResume to see if it tells the 
view to invalidate.


If your list view is backed by a managed cursor, the latter will be 
requiried around the time of onResume, in turn causing the list view to 
fully update.


-- Kostya



Cheers,
Olof


--
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: What is wrong with Android Adapters?

2012-02-15 Thread Kostya Vasilyev

On 02/15/2012 11:09 PM, Olof Hedman wrote:

Wait a while after the power turns off and check your logs, I'm pretty
sure you will se a couple of "getView":s in your logs too.
It doesn't come right away, but within a minute or so after the screen
goes black.
I took a break for over 10 minutes, leaving logcat running, and... 
sorry, it just doesn't.


--
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
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en