imageview array not working

harlechguy

Member
Licensed User
Longtime User
Apologies - I know this one is my lack of understanding - but have tried to follow other examples and am missing something.

I have a panel containing labels - when clicked the text from the label is used with SQL to generate a list.

For each item in the list I would like to place an image in an adjacent panel.

for the images I am looking to use a dynamic array of images (dependant on how many items are in the list)

my code is as follows - the label click, sql elements work fine - but my understanding of image arrays is sadly lacking :BangHead:

any help appreciated. thanks

B4X:
Sub lbl_click
Dim lb As Label
Dim tnode As node
Dim testa As String
Dim testb As String
Dim cursor1 As Cursor
Dim l As Int
Dim t As Int
Dim c As Int

l = 0
t = 5

lb = Sender
tnode = lb.Tag
testa = tnode.tag
testb = lb.Text

Dim datam As String
      
      cursor1=sql1.ExecQuery2("select Section from Sections where Manual =?",Array As String(testb))
      c = cursor1.RowCount
      Dim imageview2(c) As ImageView
      For i = 0 To cursor1.RowCount -1  
      cursor1.Position = i

      datam = cursor1.GetString("Section")
      l = l +5
      Panel2.AddView(imageview2(c),l+5,t,25,25)
      imageview2(i).tag = i
      Next

End Sub
 

klaus

Expert
Licensed User
Longtime User
At least this line
B4X:
Panel2.AddView(imageview2(c),l+5,t,25,25)
should be
B4X:
Panel2.AddView(imageview2(i),l+5,t,25,25)
Are you sure that you move the ImageViews only 5 pixels horzontally?
They will be overlapping.
What are you doing with the variable datam ?
Don't you add an image to the ImageViews ?

Best regards.
 
Upvote 0

harlechguy

Member
Licensed User
Longtime User
Thanks Klaus - tried using variable (i) no success

What are you doing with the variable datam ? will be using this to select the correct image.
Don't you add an image to the ImageViews ? will be adding this based on variable datam

have removed as much code as possible to try and work out where I am going wrong.

When I test the program in debug mode using B4A-bridge program gets to line
Panel2.AddView(imageview2(i),l+15,t,25,25)
and then force closes on the tablet - leaving little info behind

any ideas - have zipped the program if that helps show me the error of my ways!!

cheers
 
Upvote 0

harlechguy

Member
Licensed User
Longtime User
Thanks Klaus - still missing something - selected the zip but did not upload

have now attached - cheers
 

Attachments

  • DocBrowser.zip
    22.5 KB · Views: 184
Upvote 0

harlechguy

Member
Licensed User
Longtime User
Klaus, that is very much appreciated.

I copied the original node script and amended it (badly - which is the problem with being 45 and having programming skills similar to a teenagers bedroom tidying skills!).

I do not think I would have ever found that line.

thanks again
 
Upvote 0
Top