Anybody? :-) On Thursday, June 3, 2010, Mariano Kamp <[email protected]> wrote: > Hi. > Just watched Google IO's "World Of ListView" presentation [1]. Awesome stuff. > I think every Android dev should watch it. > One gotcha for me was to use BaseAdapter.notifyDataSetChanged[2]. I checked > code that I have written more than a year ago and found that I did try to use > that, but commented it out with '// doesn't work' and I use requery() > instead. That is of course much slower. > > I now tried to find out why I wrote that it didn't work and hoped that I am > meanwhile so much wiser that it would be easier to understand the proper use > of the API. So much for ambition: The effect I see is that the list is not > updated after I call notifyDataSetChanged(), but works with requery() and I > am not so much wiser ;-( > > What could be the issue here? I use a ResourceCursorAdapter and only > implemented the bindView() Method. This method is called when I call > notifyDataSetChanged() on the RCAdapter. However the method is called with a > cursor that contains the stale data. > > Now there was a second gotcha from the presentation that I couldn't really > place. It was said that the data should be committed on the GUI thread too > (before calling notifyDataSetChanged()). I couldn't place it then, but I now > suspect that this may be the issue here. So the rule would be to do the > commit() on the Cursor on the UI thread? > I do the updates to the database using a Service. This Service runs in the > background, sometimes the app is in the foreground at the same time, but most > often not. So I don't see how I should commit something in a UI thread? Is > this the issue here? There are two different Cursors and I could only use > notifyDataSetChanged when it would be the same cursor, otherwise requery() is > correct? > > Is that it? Any ideas? > Is somebody going to write a book "The Android SDK - The missing manual"? ;-) > Cheers,Mariano > > [1] http://code.google.com/events/io/2010/sessions/world-of-listview-android.html[2] > > http://developer.android.com/reference/android/widget/BaseAdapter.html#notifyDataSetChanged() >
-- 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

