Maybe related, maybe not...

I use a CursorAdapter to update a list - whenever the list refreshes
(due to the database changing) the 'onBindView()' for a given position
always seems to deliver me a *different* view from the one that
originally contained the list item.  So, during the update at least
some of the list-items are actually re-ordered and re-drawn. (Just as
you describe above)

The reason I found out about this behavior was because I was
(incorrectly) only overriding the 'onNewView()' method - making the
assumption that once the view was created its content would remain
fairly static.  This was causing all sorts of fun and games with the
UI.

Now that I follow "The Rules" and faithfully fill in whichever view I
am handed in the onBindView() (rather than try to second guess the
platform) everything is sweet.

Doug

On Jun 26, 3:48 pm, Peter <[email protected]> wrote:
> On Jun 26, 5:59 pm, Mark Murphy <[email protected]> wrote:
>
> > Peter wrote:
> > > Sorry. I'm making the mistake of hoping people identify the problem
> > > based on not very much information, partially because I'm lazy, I
> > > guess.
>
> > I may also simply be a bit thick.
>
> > > Row 0 in the ListView contains an ImageView. Initially, all rows have
> > > a placeholder image. The thread updates row 0's ImageView
>
> > "The thread"?
>
> Well, the thread sends a message to a Handler. Incidentally, the
> Handler is what kicks off the icon-grabbing thread as well. I am using
> a similar pattern to this:http://tinyurl.com/p5hlxz(Android source
> link).
>
>
>
> > That better be "the UI thread". Anything else should blow up and would
> > be unreliable if it somehow doesn't blow up. Always update your UI via
> > the UI thread.
>
> > So, for example, if you use AsyncTask for your data fetch and UI update,
> > you would do the HTTP operations in doInBackground() and update the list
> > in onPostExecute().
>
> I am doing the equivalent of that, as far as I can tell.
>
>
>
> > > and I see
> > > the image updated on the screen. A split-second later, row 5's image
> > > is the same as row 0. So now, 0 has the new image, 1-4 still have the
> > > placeholder, and 5 shows the image associated with row 0.
>
> > That is pretty strange.
>
> > Have you either used Eclipse breakpoints or Log statements to see when
> > getView() is called? In the pattern you're describing here, how many
> > times is it called?
>
> > --
> > Mark Murphy (a Commons 
> > Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> > Android Development Wiki:http://wiki.andmob.org
>
>
--~--~---------~--~----~------------~-------~--~----~
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