0

I want to load some images in a ScrollView in basic4android. This happened only once.

My Code:

Activity.LoadLayout("main")
Dim b As Bitmap
    Dim iv As ImageView
For i=1 To 10
b.Initialize(File.DirAssets,"1.png")
iv.Initialize("")
iv.Bitmap = b
ScrollView1.Panel.AddView(iv,30dip,30dip,212,64)
Next

instead of 10 image, only one image appears in my ScrollView. I need your help. Thanks.

Davlog
  • 2,162
  • 8
  • 36
  • 60
Salar Ashgi
  • 128
  • 2
  • 13

2 Answers2

1
For i = 10
    Dim iv As ImageView 'create an ImageView for each bitmap
    iv.Initialize("") 'not interested in any events so we pass empty string.
    Dim bd As BitmapDrawable
    bd.Initialize(Bitmaps.Get(i))
    iv.Background = bd 'set the background of the image view.
    'add the image view to the scroll bar internal panel.
    ScrollView1.Panel.AddView(iv, 5dip, 5dip + i * 200dip, ScrollView1.Width - 10dip, 190dip)
Next

Try the above code that "should" work, I am not near B4A to test it but all the code looks right on my example.

0

always addview on top 30dip

ScrollView1.Panel.AddView(iv,30dip,30dip,212,64)

Change value

ScrollView1.Panel.AddView(<Image>,<Left>,<Top>,<H>,<W>)