Panels vs Activities

Bill Norris

Active Member
Licensed User
Longtime User
Will ultimately be developing an app for a tablet. There will be somewhere in the vicinity of 10-15 different screens that the user can navigate back and forth to, each containing a variety of views. In vb.net, I would simply have a form for each screen and manage them accordingly. In B4A, should I:

1: Build a separate panel for each screen, and make them visible/invisible as appropriate?
OR
2: Have each screen be a separate activity, and load/unload as appropriate?
OR
3: Build and save each screen as a separate layout, then, use one activity, load the appropriate layout as needed?

NOTE: Some the screens may have persistent values in some of the views that should remain if the user navigates back to that screen, others will not.

Thanks for the help.
 

canalrun

Well-Known Member
Licensed User
Longtime User
Will ultimately be developing an app for a tablet. There will be somewhere in the vicinity of 10-15 different screens ...

1: Build a separate panel for each screen, and make them visible/invisible as appropriate?

I use method 1 and it works very well.

In addition to the visible/invisible I enable/disable. Don't know if it matters …

Barry.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Me too, I would choose either solution 1 or 2.

Solution 1 is probably more responsive, because the views in the panels are already loaded. When hiding and showing again all parameters are maintained, as long as you don't turn the device. When you turn the device you must manage which one was the last visible panel and show this one.

Solution 2 is more Android oriented. A little less responsive but less memory needed, only one layout. Easier to manage when turning the device, the current activity is reused. In my last projects I tend to priviledge solution 2. Keeping values across activities can be managed with process global variables.

I would not recommend solution 3.

Best regards.
 
Upvote 0

admac231

Active Member
Licensed User
Longtime User
I would use #2. Is that not how Vb.net works anyway? When you close a form it's disposed of? Although I may be confusing it with C#.

Like klaus said, the management of variables between forms can very easily be accomplished with global variables.
 
Upvote 0

COBRASoft

Active Member
Licensed User
Longtime User
After some research and asking around, N° 2 for sure.

For the variables, you could make a type per activity in a global code module. That way you can share them with another activity if required. Restoring an activity will be easier and cleaner this way since all variables will be in 1 type at all at the same place. See a type as a kind of data class in VB.Net. Easy accessible, also easy to make a List of it if needed...
 
Last edited:
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Plus No 2 makes handling the hardware back button automatic

Sent from my DROIDX
 
Upvote 0
Top