help on check box and other buttons

Rioven

Active Member
Licensed User
Longtime User
Hello everyone,
B4A newbie need help.
Could anyone please direct me to a nice sample on how to handle and storing check box values to a file to initialize my applications.

I've also noticed that when the device is rotated to landscape or portrait all my check boxes turned unchecked. thanks.
 

klaus

Expert
Licensed User
Longtime User
There are two possibilities:
- if you just need to store the setup parameters just during the running of the program:
store the setup variables in a Map or a List declared in Sub Process_Global
set the Checkboxes in Activity_Create
save the setup variables in the Map or List either directly when they are changed or in Sub Activity_Pause
- if you need to remember the setup also after leaving the program:
like above, but saving the Map or List to a File in Sub Activity_Pause and reading the file in Activity_Create when FirstTime = True.

When the Device is rotated the current activity is Paused and can even be destroyed by the OS and the Activity is again generated with Activity_Create and Activity_Resume.

Best regards.
 
Upvote 0

Rioven

Active Member
Licensed User
Longtime User
hopefully I got it!

Hi Klaus!

Thanks for This! You're great! I will try it later.
To recap(...if I did understand well...pls. correct me if I'm wrong or some other tips).

1) Under Sub Process_Global Declare Variables, Map, or Lists which are also be used for device rotation subs-pause/resume.

2) Under Sub Activity_Create
If the ini.file exist=False then...
RUN the checkbox values programmatically just for the FIRST TIME and save to create ini.file.
ELSE retrieve ini.file
.
.
Then reflect to checkboxes display status.
.
.

3)Under Sub Activity_Pause It requires codes to store the checboxes values.

4) Under Sub Activity_Resume and values stored be retrieved at
(Just now I know the purpose of these subs...hmmm...FOR DEVICE ROTATIONS:))am catching up reading threads and I'm still on page50:sign0148:

5) Save to ini.file whenever...

The above as well to be applied on other buttons/TextReader etc.properties, contents or states not to be destroyed during device rotations.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
1) Yes
2) Yes
3) Yes
4) If you have retreaved the values in Activity_Create you don't need to do it in Activity_Resume.
5) you can save the file when you quit the program if you have saved the parameters in a Map or List otherwise you must save it at latest in Activity_Paused.

Best regards.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
4) If you have retreaved the values in Activity_Create you don't need to do it in Activity_Resume.
Not so I'm afraid Klaus. Activity_Resume is the best place to restore stuff. You can get an Activity_Pause followed by an Activity_Resume without going through an Activity_Create, for example if the user presses the Home key and then restarts your app.
 
Upvote 0

Rioven

Active Member
Licensed User
Longtime User
Thank you!

Thanks Klaus and Andrew!
This is a good start for me on how to basically structure my applications as I go on with my B4A codings.
In addition...
I would like to make modules that could be used easily be applied or modified for my other future projects.
Then I must declare module Variables to Sub Process_Globals at Main module only, is that correct?

thanks again!

With best regards,
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Then I must declare module Variables to Sub Process_Globals at Main module only, is that correct?
No. Variables declared in an Activity, Code or Service Module Sub Process_Globals are global to the application and can be accessed from other Activity, Code and Service Modules.
 
Upvote 0
Top