Tuesday, February 14, 2012

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

did you use addHeaderView() in your code?

On 14 fév, 10:22, jamesc <jame...@gmail.com> wrote:
> Also, are you calling notifyDatasetChanged() frequently?
>
> On Feb 14, 9:10 am, jamesc <jame...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hello
>
> > Are you using the ViewHolder pattern to recycle Views?
>
> > On Feb 13, 9:48 am, Olof Hedman <o...@illusionlabs.se> 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 - 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@405877c0
> > > position: 0 - to: A5D7W5U9.02
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405743e0
> > > position: 1 - to: ASQK89Q8.58
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@40548088
> > > position: 2 - to: ASQK89Q8.37
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405a85f8
> > > position: 3 - to: AEURWHRA.02
> > > D/SLPA    ( 4097): binding View - android.widget.LinearLayout@405ab368
> > > position: 4 - to: ASQK89Q8.44
>
> > > Why on earth would it need to do this when it turns off the screen?!
>
> > > 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.

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

No comments:

Post a Comment