ImageView array question

MiniDemonic

Member
Licensed User
Longtime User
Is it possible to create a variable amount of ImageViews?
All the array codes I have seen is something like:
B4X:
imgarray = array as imageview(img1, img2, img3)

But my question is if it is possible to do something like:
B4X:
Pseudocode:
for i = 0 to list.size - 1
 add imageview("img"&i) to imgarray
next

I have searched and searched so I'm starting to think that this is impossible. :sign0148:
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Yes.
Use a List instead of an array.
B4X:
Sub Globals
   Dim ImageViews As List
End Sub

Sub Activity_Create(FirstTime As Boolean)
   ImageViews.Initialize
   For i = 0 To 99
      Dim iv As ImageView
      iv.Initialize("iv")
      ImageViews.Add(iv)
   Next
   
   'Later to retrieve imageview #57
   Dim iv As ImageView
   iv = ImageViews.Get(57)
End Sub
 
Upvote 0

MiniDemonic

Member
Licensed User
Longtime User
Thank you!
It works great, btw Erel, is there any place here where we can upload/post applications that only visitors with a B4A license can see?

I would like to release my apps for free to the B4A community but sell them on Android Market for the rest.
 
Upvote 0

ktlua

Member
Licensed User
Yes.
Use a List instead of an array.
B4X:
Sub Globals
   Dim ImageViews As List
End Sub

Sub Activity_Create(FirstTime As Boolean)
   ImageViews.Initialize
   For i = 0 To 99
      Dim iv As ImageView
      iv.Initialize("iv")
      ImageViews.Add(iv)
   Next
  
   'Later to retrieve imageview #57
   Dim iv As ImageView
   iv = ImageViews.Get(57)
End Sub
 
Upvote 0

ktlua

Member
Licensed User
Yes.
Use a List instead of an array.
B4X:
Sub Globals
   Dim ImageViews As List
End Sub

Sub Activity_Create(FirstTime As Boolean)
   ImageViews.Initialize
   For i = 0 To 99
      Dim iv As ImageView
      iv.Initialize("iv")
      ImageViews.Add(iv)
   Next
 
   'Later to retrieve imageview #57
   Dim iv As ImageView
   iv = ImageViews.Get(57)
End Sub

May I know how to add image to the ImageViews. Thanks!
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You should always start a NEW THREAD in the questionsforum if you have any question.
Adding THREE Posts on a 4 year old thread is the wrong way to ask for help.
 
Upvote 0
Top