If you're loading or generating the images on multiple non-UI threads,
they are probably being added to the view in the order they complete
(of very near that).  If that is not what you want, there are two
things you can do to fix that.

The simplest is to serialize the loading or genration in one thread.
That is, load one image, call runOnUiThread with a runnable to insert
it into the UI, then repeat to load more images.

The more complicated route is to build a synchronized buffer queue (of
sorts) that can store references to the images while wait on others to
complete.  This can either be explicit buffer over built on an array
like structure, or implicitly with something like a chain of
semaphores.  In general, the loader for image #2 will wait for the
loader thread of image #1 to complete its UI update.  This is not
straight forward code, and you need to be very carefully about
exceptions and other edge cases.  Nothing in the that I know off in
the standard libraries will provide this out of the box.




On May 30, 1:27 am, gaurav gupta <gaurav.gupta...@gmail.com> wrote:
> Hi Guys,
> M using runonUiThread to set images in a Gridview. its working fine but its
> load images randomly, i want that images load in sequence order , not
> randomly.
> please Suggest how  can i do that.

-- 
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

Reply via email to