iOS Question Album from asset images and scrollview slideshow.

narek adonts

Well-Known Member
Licensed User
you can create a folder with File.MakeDir and use File.Copy to copy your image files to that folder.
To show it as an photo album you will need some Gride View. As as I know there is no open source gride view for b4i you can implement yours with a scrollview.
 

Mashiane

Expert
Licensed User
Ok, this is what I have tried, everything seems to be working but when my page opens, only the last image is shown.

1. I created a view with a panel and inside this panel a label and an image view, I call this layout slideImage. It's designer scripts are:

B4X:
pnlMaster.SetLeftAndRight(0, 100%x)
pnlMaster.SetTopAndBottom(0, 100%y)
lblTitle.SetLeftAndRight(0, 100%x)
lblTitle.SetTopAndBottom(0, 10%y)
imgPicture.SetLeftAndRight(0, 100%x)
imgPicture.SetTopAndBottom(10%y, 100%y)
Then I created another layout with a scrollview inside with pagination enabled, with its script being:

B4X:
svSlideShow.SetLeftAndRight(0,100%x)
svSlideShow.SetTopAndBottom(0, 100%y)
Now, I read my images from a database like this...

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
The page shows and shows the last image, how do I get the scrollview to show the first image i.e. first view added and then provide a way to slide through the images.
 
Top