Many screens - one program

LineCutter

Active Member
Licensed User
Longtime User
I want to write a program that will offer a choice of equations & then calculate the answer. The data required varies, to the point of requiring a screen per equation in order to make it usable.
e.g.
Equation 1: Variables: Height. Width. Length
Calculation 1: Display calculated volume

Equation 2: Variables: Speed. Time
Calculation 2: Display calculated distance

As you can tell, this will require multiple screens to be displayed for the user.

I seem to have the options of:
  • Making a series of stand alone activities, with a launcher activity acting as broker
  • Using one activity. Deleting all of the views & loading a new layout to match each equation
  • Using a panel per equation, creating these as I go or all at the program launch & then hiding them until they need to be displayed
  • Using one panel - deleting everything & loading layouts as required.
I've probably missed the best option :)

Before I plough into doing this the hard (trial & error) way, does anyone have a suggestion for the best way to handle this??
 

mjcoon

Well-Known Member
Licensed User
I tried using multiple panels but gave up because the Designer shows panels in the same z-order as will be used in live and provides no convenient way to choose one to show.

Whereas it is slightly easier to switch between forms to work on (though not so easy to copy controls between forms).

There is also the problem of menus, which are shared between panels but have to be replicated across forms. And also that forms are liable to show up as distinct if you display the running tasks on the device.

At least, I worked out a way to use MainMenu.dll to replicate menus across forms, so that the menu only has to be maintained via Designer on one "template" form.

With Erel so heavily involved with B4A we are not likely to get enhancements of the B4P Designer...

Mike.
 

klaus

Expert
Licensed User
Longtime User
I would do it that way:
-n Labels with the text of the variables
n=max. number of variables needed
-n TextBoxes for the variable values
-1 Label for the text of the result
-1 Label for the result value
-1 Button for the calculation
-1 ListBox to select the equation
Then according to the selected equation:
- hide the Labels and TextBoxes which are not needed
- set the texts for the different variables and the result

The advantage is:
- a very low number of Controls
- one routine for the equation setup
with
Select Equation
Case Equ1
Case Equ2
etc

- one routine for the calculation
Select Equation
Case Equ1
Case Equ2
etc
- very easy to add a new equation

The disadvantage is:
- a little more complex code.

Best regards.
 
Top