Android Question Retrieve values of image index

Francisco Barbosa

Member
Licensed User
Longtime User
I analyzed the code of "How can i add click functions to imageviews Which are in a scroll box?" and I observed the following:

I used the same object ImageView loop, applied a tag to store the value, but when I click the image the result is always the last stored. How to get retrieve the other values?
 

DonManfred

Expert
Licensed User
Longtime User
show your code which adds the tag... Including the dim... Without seeing a code i just can guess what you are doing wrong

Maybe you are doing it like this way?

B4X:
DIM tv as string
for i = 0 to 100
  tv = i
  ' code for creating imageview here  
  imageview.tag = tv
next

And then (in this example) all imageviews have a Tag of "100"... Right?

If that is the case then try this:

B4X:
for i = 0 to 100
  DIM tv as string
  tv = i
  ' code for creating imageview here  
  imageview.tag = tv
next

NOW each imageview have the Tag which expected. 0, 1, 2, 3, ..., 100
 
Last edited:
Upvote 0

Francisco Barbosa

Member
Licensed User
Longtime User
Hello Don,

Thanks for your attention.
Exactly how I'm doing, the problem is in cllick event:

Sub imageview_Click ()
Msgbox (imageview.Tag, "Click")
end Sub

The value displayed is the last: 100

HERE IS THE PART OF CODE:

for i = 0 to list.lenght - 1
url = "http://www.webaddress.com/user/" & list(i)
'Dim img As ImageView
img.Initialize(list(i))
img.Tag = list(i)
Picasso1.Initialize
Picasso1.LoadUrl(urlImage).Scale(0.20).IntoImageView(img)
next

So I have a event Click (img_click). The big problem is retrieve the contents of several img elements.
 
Upvote 0
Top