When I do 5 times LOADLAYOUT, app is slowly

petr4ppc

Well-Known Member
Licensed User
Longtime User
Dear friends,

I know, that it can be one of basic question, but help me please.

When I open 5 different layouts in one scrollview via loadlayout, then scroll function is slow. I am trying to do:

1)
removeview
http://www.b4x.com/forum/basic4andr...-android-process-activities-life-cycle-2.html
2)
If panel1.IsInitialized=True Then panel1.Enabled=false
If panel2.IsInitialized=True Then panel2.Enabled=false

but this can not solve my trouble. I have read forum, but I cant find something what help me..

When I push BACK BUTTON and then I start APP again, everything is OK, but when I open all of my layouts, scroll is slow again...

I am opening 10 small jpg images in each layout

Please very much, what can I do?
Thank you
p4ppc
 

petr4ppc

Well-Known Member
Licensed User
Longtime User
It looks, that trouble was because I do everytime, when I load each layout and each image:

B4X:
   If File.Exists(File.DirInternal,"image3.gif")=True Then 
     image3 = LoadBitmapSample(File.DirInternal, "image3.gif", 100%x*scale, 100%y*scale) 
     ImageView3.SetBackgroundImage(image3)    
   End If

and now I have in code only

When I start app first time then I read images:
B4X:
 image3 = LoadBitmapSample(File.DirInternal, "image3.gif", 100%x*scale, 100%y*scale)

and when I load layout then I use:

B4X:
   If File.Exists(File.DirInternal,"image3.gif")=True Then 
         ImageView3.SetBackgroundImage(image3)    
   End If

and it looks good...I hope....because I will add layouts with images

:sign0148:
Thank you Erel,
p4ppc
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Hi petr4ppc,

If you have ever read Klaus 's Beginer Guide,You could see his technique.
load the Image only one time.

If FirstTime Then
Img3=LoadBitmap(File.DirInternal, "image3.gif")
End If
 
Upvote 0
Top