Android Question array of view

RUNO

Active Member
Licensed User
Longtime User
If I want to display images by defining an array of images
How do I get an index for the image that we click on to enlarge it or get information for it

B4X:
 Dim count As Int=1
Dim imvw As Int=30%x
 Dim imvh As Int=100dip
 Dim imvl,imvt As Int =0
  
    For i=0 To 25 'sample
        Log(i & " " & count & " " & imvl& " " & imvt)
        imv(i).Initialize("imv")
        imv(i).Gravity=Gravity.FILL
        imv(i).Bitmap=LoadBitmap(File.DirAssets,"icon.png") 'sample
        sv1.Panel.AddView(imv(i),imvl,imvt,imvw,imvh)
        If count<3 Then
            imvl=imvl+30%x+10dip
            imvt=imvt
            count=count+1
        Else
            
            count=1
            imvl=0%x
            imvt=imvt+100dip+40dip
        End If
    Next
 

DonManfred

Expert
Licensed User
Longtime User
You can use the Tag to store infos about the Image.
B4X:
 imv(i).Tag = i
instead of just storing i you also could store a map with more infos in the Tag. It is up to you.
 
Upvote 0
Top