I understand. It is hard to ask accurate questions via text. I think DonManfred has my answer, but to clarify: Depending on how often the user wants to return to the same layout, it may get loaded many times. My concern is if I need to do something to "clean it out" before loading the same one again, or will it keep building up somewhere in memory and causing some resource limit to be exceeded.I'm not sure what you are asking. Existing views will never be removed as a result of calling LoadLayout.
I understand. It is hard to ask accurate questions via text. I think DonManfred has my answer, but to clarify: Depending on how often the user wants to return to the same view, it may get loaded many times. My concern is if I need to do something to "clean it out" before loading the same one again, or will it keep building up somewhere in memory and causing some resource limit to be exceeded.
Computersmith6, thank you for your reply. I used the wrong word "view". I changed the word "view" to "layout" in my previous question.Do you mean the user goes from your main activity to another activity & then returns to the main activity (& does so multiple times)? AFAIK the main activity stays in memory unless the OS needs to kill it - in which case it will be reloaded when the user returns to it. Either way there is never more than one instance of the activity & its related layout & views.
- Colin.
Calling LoadLayout will load a new layout on top of the existing activity or panel, no? Unless we use RemoveAllViews.I think @Erel answered that already by saying that existing views are removed as a result of calling LoadLayout - ie: the layout is effectively reset. The question is: why would you want to load the same layout multiple times in an activity? It doesn't sound like something you would normally do, so perhaps there's another way to achieve whatever it is you're trying to achieve?
- Colin.
Oops - yes. I misread Erel's reply. Still begs the question as to why you would want to load the same layout multiple times...Calling LoadLayout will load a new layout on top of the existing activity or panel, no? Unless we use RemoveAllViews.
I have the same practice that I use the same Activity or B4XPage, let say I call it User. I called different “mode” from other starting module to load different layouts such as “Login”, “Register”, “Reset Password” in a single activity or page.Oops - yes. I misread Erel's reply. Still begs the question as to why you would want to load the same layout multiple times...
- Colin.
Activity.RemoveAllViews ' remove all it's child views
Activity.RemoveViewAt(0) ' remove it's child view with index 0
panel.RemoveAllViews ' remove all it's child views
panel.RemoveViewAt(0) ' remove it's child view with index 0
panel.RemoveView ' remove itself from it's parent
label.RemoveView ' remove itself from it's parent
Activity and Panel which can contain other views, both can remove it's child views.
While Panel is also a view and other views such as Label can remove itself.
B4X:Activity.RemoveAllViews ' remove all it's child views Activity.RemoveViewAt(0) ' remove it's child view with index 0 panel.RemoveAllViews ' remove all it's child views panel.RemoveViewAt(0) ' remove it's child view with index 0 panel.RemoveView ' remove itself from it's parent label.RemoveView ' remove itself from it's parent
[...] and there must be lots of apps created by B4a on Google Play. [...]
For me, the answer is simply none of the apps will load several times the same layout, sorry for being crude, it's non sense.Yes - but I doubt that many of them (if any) are calling LoadLayout to reload the same layout multiple times.
Thanks much, aeric. I'll play around with these to see if they help.
For me, the answer is simply none of the apps will load several times the same layout, sorry for being crude, it's non sense.
I think your findings is good and useful to remind us to avoid this kind of thing to happen. I will bear in mind when my apps need to publish to play store.I want to thank everyone for replying to my questions, and extend that thanks to RB Smissaert's recent reply and coding suggestion. And Klaus, I take no offense. I agree that you and the others with the same comment are absolutely correct.
Before you all think I am a total goofball, I need to tell you that I never intended for a user to do the same load layout multiple times, and I will insert code to make sure that doesn't happen. However, when my app updates release to Google Play, as part of their internal testing process, they are being tested by a robot they use to put an app through its paces. I noticed it pressing the buttons multiple times. I decided to see what would happen if I did that.
I discovered that after pressing the same button about 40 times in a row, causing the same loadlayout to be executed that many times in a row, performance began to slow down noticeably. When it did I could even wait several minutes before pressing again, and performance of the loadlayout was still slowed, so it wasn't my code buffering up causing that. This tells me that the loadlayout is building something up in memory and affecting performance somehow. I thought someone ought to know that, and maybe they already do. As far as I'm concerned, and if no one else is concerned, at this point, this question of mine can be closed out.
Again, thank you everyone. This is the best forum I have ever used.