That's probably because your ListView has a height set to wrap_content. Which is a bad idea. Also, there is absolutely NO guarantee that getView() will be called only once per item or in the right order.
On Tue, Aug 10, 2010 at 5:25 PM, Open <[email protected]> wrote: > I'm seeing the same thing and wondering the same. In my case I'm > fetching an internet resource in setViewValues so calling it three > times is very expensive. > > > On Jul 30, 3:39 pm, William Ferguson <[email protected]> > wrote: >> Hi all, I have a ListView populated using a SimpleCursorAdapter that >> has a ViewBinder, and I'm finding that when the ListView is displayed, >> ViewBinder#setViewValueis called 3 times for each row of the cursor. >> >> Once during onMeasure: >> at au.com.xandar.contactsmanager.DisplayContactsActivity >> $1.setViewValue(DisplayContactsActivity.java:56) >> ... >> at android.view.View.measure(View.java:8171) >> at android.view.ViewRoot.performTraversals(ViewRoot.java:801) >> at android.view.ViewRoot.handleMessage(ViewRoot.java:1727) >> at android.os.Handler.dispatchMessage(Handler.java:99) >> at android.os.Looper.loop(Looper.java:123) >> at android.app.ActivityThread.main(ActivityThread.java:4627) >> at java.lang.reflect.Method.invokeNative(Native Method) >> at java.lang.reflect.Method.invoke(Method.java:521) >> at com.android.internal.os.ZygoteInit >> $MethodAndArgsCaller.run(ZygoteInit.java:868) >> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java: >> 626) >> at dalvik.system.NativeStart.main(Native Method) >> >> Once during onLayout: >> at au.com.xandar.contactsmanager.DisplayContactsActivity >> $1.setViewValue(DisplayContactsActivity.java:56) >> ... >> at android.view.View.layout(View.java:7035) >> at android.view.ViewRoot.performTraversals(ViewRoot.java:1045) >> at android.view.ViewRoot.handleMessage(ViewRoot.java:1727) >> at android.os.Handler.dispatchMessage(Handler.java:99) >> at android.os.Looper.loop(Looper.java:123) >> at android.app.ActivityThread.main(ActivityThread.java:4627) >> at java.lang.reflect.Method.invokeNative(Native Method) >> at java.lang.reflect.Method.invoke(Method.java:521) >> at com.android.internal.os.ZygoteInit >> $MethodAndArgsCaller.run(ZygoteInit.java:868) >> at com.android.internal.os.ZygoteInit.main(ZygoteInit.java: >> 626) >> at dalvik.system.NativeStart.main(Native Method) >> >> And the third time from onMeasure again. >> >> Firstly, is this expected behaviour? >> >> If it is, then what's the best way of performing potentially expensive >> work in ViewBinder#setViewValue? >> For example, retrieving the results of another cursor whcih is used to >> construct the bound view. >> >> Or am I approaching this from entirely the wrong view point? >> >> William > > -- > 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 > -- Romain Guy Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support. All such questions should be posted on public forums, where I and others can see and answer them -- 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

