iOS Question Help Creating Slideshow with scrollview

Mashiane

Expert
Licensed User
Longtime User
Hi

I'm trying to create an image slideshow using a scrollview, Im reading my images from the database, everything works fine, but the only image that gets shown is the last image but when i count the number of views in the scrollview it returns the right number of images.

B4X:
Sub LoadSlideShow()
    b4iMash.ShowProgress("Loading slideshow...")
    b4iMash.OpenDb
    ' clear all views in the panel
    svSlideShow.Panel.RemoveAllViews
    Dim cur As ResultSet
    Dim sPath As String
    cur = b4iMash.Table_OpenRecordset(b4iMash.SQLite,"select * from [Pictures] order by [Key]")
    Do While cur.NextRow
        Dim sKey As String: sKey = cur.GetString("Key")
        Dim sText As String: sText = cur.GetString("Text")
        Dim sTag As String: sTag = cur.GetString("Tag")
        sPath = sTag.replace("[","")
        sPath = sPath.replace("]","")
        sPath = sPath.replace(",","")
        sPath = sPath.replace("-","")
        sPath = sPath.ToLowerCase & ".jpg"
        ' load a new panel and inset image
        Dim pnlImage As Panel
        pnlImage.Initialize("")
        pnlImage.LoadLayout("slideImage")
        ' get the parent panel
        pnlMaster = pnlImage.GetView(0)
        ' get the label inside the panel
        lblTitle = pnlMaster.GetView(0)
        lblTitle.Text = sText
        imgPicture = pnlMaster.GetView(1)
        imgPicture.Bitmap = LoadBitmap(File.DirAssets, sPath)
        svSlideShow.Panel.AddView(pnlImage,0,0,svSlideShow.Width,svSlideShow.Height)
        svSlideShow.ContentWidth = pnlImage.Width
        svSlideShow.ContentHeight = pnlImage.Height
    Loop
    cur.close
    b4iMash.HideProgress
End Sub

Can anyone please advise please?
 

Brian Robinson

Active Member
Licensed User
Longtime User
B4X:
        svSlideShow.Panel.AddView(pnlImage,0,0,svSlideShow.Width,svSlideShow.Height)

Hi,

It looks like you are just putting the pnlImage objects over the top of each other.

I think it would need something like this.

B4X:
Dim counter As Int = 0
Do While cur.NextRow
    svSlideShow.Panel.AddView(pnlImage,counter*svSlideShow.Width,0,svSlideShow.Width,svSlideShow.Height)
    counter = counter+1
Loop
svSlideShow.ContentWidth = svSlideshow.Width * counter
 
Upvote 0
Top