Android Question 2 modules 2 layouts

Richard P

Member
Licensed User
Longtime User
I have a module1 with a layout1 in which i enter text into three EDITTEXT views (surname, given name and DOB).
I then switch (startActivity(main)) [Main being the name of module2] with a layout2 which is the same as layout1 except the three EDITEXT views above are LABELS.
This is where I want to enter the information entered in layout1 - but it comes up blank.

I have read the 'Activity life cycle' in the users guide but not got any further forward.

Is it easier to have 1 main module with a code module - if so how do you call a sub in a code module and where do you declare the variables.

I was hoping to use Klaus's 'SQLiteLight1' example to build on the current project to save the data entered into a database but i can't get passed the basics.

What an i missing

One frustrated new coder
 

stevel05

Expert
Licensed User
Longtime User
It will depend on how you are passing the data to the second module, calling it main is not a good idea as the Main module is just that, and will be the first to run (not sure how you did that as I would think you would get an error). The fastest way to get a helpful response would be to zip (from the file menu) and post your project (via upload file). We will then know exactly how you are going about it and will be better placed to advise.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Hi Richard .. personally I would organize your activity naming first. Name the first activity "Main" loading "layout1". (this is where you enter data to the DB)
The second activity = "Activity2" loading "Layout2". (this is where you display the data)
.. stops any confusion.

As steve05 has suggested .. post your project and we can help more.
 
Upvote 0

Richard P

Member
Licensed User
Longtime User
Forgive the crudity of the coding - hopefully attached is the file i am working on.

The idea is that i want to build on this and test stage by stage. The next step was to try saving to a database then display linked persons in a scrollview or list. Both of which i have dabbled with without success.

If i can get this working i want to fill the database from a spreadsheet holding existing date and then attach to each person, one or more jpegs or pdf files. Ambitious when you see where i am stuck. Klaus helped with a similar problem displaying numbers entered in an EDITTEXT view into a label so thought this would be the same or similar .........

Thanks for the response and look forward to your feedback once you have topped laughing!!!!
 

Attachments

  • FH3 trial.zip
    9.7 KB · Views: 137
Upvote 0

James Chamblin

Active Member
Licensed User
Longtime User
Read the beginner's guide Chapter 13.2 "Program with 3 activities" to see how to communicate between separate activities. Also, you don't need StartActivity("Main") in the addperson activity; instead, use Activity.Finish.

To pass values between activities, you need to store the information in Sub Process_Globals. Unfortunately, you cannot put views there, so instead you need to put placeholders there and copy the information to the view in Sub Activity_Resume.

I have altered your code and placed comments where I changed things. Hopefully between the Beginner's Guide and my example you should be able to figure out what is done.
 

Attachments

  • FH3.zip
    10 KB · Views: 161
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Richard .. you might want to also rethink you View names.. it could become very confusing down the path. try to incorporate View type abbreviation.
for example..
B4X:
Dim lblTitleAdd As Label
Dim lblSurnameAdd As Label
Dim lblFirstNameAdd As Label
Dim lblDOBAdd As Label
Dim edtSurname As EditText   'or txtSurname
Dim edtFirstName As EditText     'txtFirstName
Dim edtDOB As EditText             'txtDOB
Dim btnViewPerson As Button
 
Upvote 0

Richard P

Member
Licensed User
Longtime User
Read the beginner's guide Chapter 13.2 "Program with 3 activities" to see how to communicate between separate activities. Also, you don't need StartActivity("Main") in the addperson activity; instead, use Activity.Finish.

To pass values between activities, you need to store the information in Sub Process_Globals. Unfortunately, you cannot put views there, so instead you need to put placeholders there and copy the information to the view in Sub Activity_Resume.

I have altered your code and placed comments where I changed things. Hopefully between the Beginner's Guide and my example you should be able to figure out what is done.
Read the beginner's guide Chapter 13.2 "Program with 3 activities" to see how to communicate between separate activities. Also, you don't need StartActivity("Main") in the addperson activity; instead, use Activity.Finish.

To pass values between activities, you need to store the information in Sub Process_Globals. Unfortunately, you cannot put views there, so instead you need to put placeholders there and copy the information to the view in Sub Activity_Resume.

I have altered your code and placed comments where I changed things. Hopefully between the Beginner's Guide and my example you should be able to figure out what is done.

Thank you for your help, I shall have a look at it tonight.

All the support from members helps keep you going when beginners like me struggle.

It is very much appreciated.

I know it's an old chestnut but, how practical is it to just have one module and one or more layouts?
 
Upvote 0

Richard P

Member
Licensed User
Longtime User
Richard .. you might want to also rethink you View names.. it could become very confusing down the path. try to incorporate View type abbreviation.
for example..
B4X:
Dim lblTitleAdd As Label
Dim lblSurnameAdd As Label
Dim lblFirstNameAdd As Label
Dim lblDOBAdd As Label
Dim edtSurname As EditText   'or txtSurname
Dim edtFirstName As EditText     'txtFirstName
Dim edtDOB As EditText             'txtDOB
Dim btnViewPerson As Button


It is difficult to come up with logical names but I can see the advantage and sense in what you say. I will look at all the post to my query tonight.

Thanks for the reply

Cheers
 
Upvote 0

Richard P

Member
Licensed User
Longtime User
Read the beginner's guide Chapter 13.2 "Program with 3 activities" to see how to communicate between separate activities. Also, you don't need StartActivity("Main") in the addperson activity; instead, use Activity.Finish.

To pass values between activities, you need to store the information in Sub Process_Globals. Unfortunately, you cannot put views there, so instead you need to put placeholders there and copy the information to the view in Sub Activity_Resume.

I have altered your code and placed comments where I changed things. Hopefully between the Beginner's Guide and my example you should be able to figure out what is done.

Hi James,

Have just sat down and run the changes you made and it works a treat. I need to study and understand a bit more what you have done and how it works but again appreciate all the help.

Without seeming to be too pushy could i ask a bit of advice / direction?
1. I would now like to work on adding more names and saving them to a database and,
2. In each of the current views would like to list for all in the database; name, surname, dob etc. tried this previously with little success.

If you could point me in the right direction

Once again thanks for the help

Richard
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Without seeming to be too pushy could i ask a bit of advice / direction?
1. I would now like to work on adding more names and saving them to a database and,
2. In each of the current views would like to list for all in the database; name, surname, dob etc. tried this previously with little success.

I have include a very bare bones example , which should get you started.
You should continue to reference and Klaus's SQLitelight1 Example ..
and certainly read up on the example apps in Section 13 of the Beginners Guide.

ps. I found this site useful when learning SQlite.. w3schools - SQLTutorial

Best of luck ..
 

Attachments

  • FH3 Example.zip
    11.9 KB · Views: 156
Last edited:
Upvote 0

Richard P

Member
Licensed User
Longtime User
I have had a brief look at your sources of further information you posted. Unfortunately its back to work in the morning but will have a more thorough look over the next few evenings. The W3school looks really useful.

Thank you

Richard
 
Upvote 0
Top