Hello !

I am developing a pictures selector which displays ImageViews in a
GridView, with a CheckBox on top of each ImageView.

2 actions are possible for the user :
- click on the checkbox to select the picture
- click on the image to display a larger view of the picture

To manage these events, I associate the logical ID of the image to the
ImageView and the CheckBox using setTag() on each, in my adapter's
getView().

So, in the onClickListener of the CheckBox and the ImageView, I should
retrieve the corresponding picture ID using getTag().

This workperfectly when the grid content is stable, but when I'm
adding items to the grid with a background thread, there are
problems :
- the checkbox listener sometimes acts on a different picture Id than
what was expected
- imageview listener always displays a different picture than what was
expected

I assume that between the time when the user clicks on the checkbox/
imageview and the time when the listener retrieves the picture id with
getTag(), the item view has been recycled as new items have been added
(the adapter calls notifyDataSetChanged on each addition).

Is there a smarter way to implement what I wanted to do ?

Thanks !

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