Betterslidingpanels with images

cazam

New Member
Licensed User
Longtime User
Hi all
Dabbled with VB over the years, and having a bash with B4A which I thought I was getting my head around until this weekend.

I have been building a flashcard program using betterslidingpanels to retrieve my images.
I inserted
panels(i).SetBackgroundImage(LoadBitmap(File.DirAssets,"Img"&i&".jpg")) as below

Dim panels(21) As Panel
For i = 0 To panels.Length - 1

panels(i).Initialize("panels")
panels(i).Color = Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255))
Dim lbl As Label
lbl.Initialize("")
lbl.Text = "I'm Panel: " & i
lbl.TextSize = 20
lbl.TextColor = Colors.White

panels(i).AddView(lbl, 20%x, 40%y, 60%x, 30dip)
Activity.AddView(panels(i), 100%x, 0, 100%x, 100%y - 0dip) 'add the panel to the layout
Activity.AddMenuItem("Panel #" & i, "Menu")
panels(i).SetBackgroundImage(LoadBitmap(File.DirAssets,"Img"&i&".jpg"))

Next

This worked well until my images exceeded 10 of 20 now it compiles OK but wont load on my Nexus 7.

So my question is
Am I physically loading all the images into memory by using the above solution, although I did reduce the image size with the same result.
my thought was also, is the "Img"&i& causing an issue as it crashes when i = 2 digits.

I managed to get it to work by loading the images within the animation1_AnimationEnd sub, but the images load to slowly

or am I going completely the wrong way about loading images into panels.

Any responses will be greatly received.
 

cazam

New Member
Licensed User
Longtime User
Hi thanks
looks like its a memory issue
I going to try and use 3 panels preloaded with 3 images and load the images on demand by
identifying if swipe is up or down, and load an additional image accordingly keeping an image ahead.
ie image 0,1,2 loaded swipe up puts preloaded panel 1 on display whilst preloading panel 2 with the next image
I'm hoping this will enable the app to run smoothly.
will update when routine completed.

If anyone has any other methods to load images in a flashcard fashion
please post

Thanks
 
Last edited:
Upvote 0
Top