Android Question passing input values from one activity to another

Zizi

Member
hi, I am trying to pass input data (using editText) from main activity and diplay them to a new actity called actDetails.

this a sample of my code:
Main:
Sub Process_Globals
Public currentStage As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")

currentStage = stage.Text
End Sub

"------------------------------------------------
2nd Activity actDetails

Sub Globals
Private lblstgDetail As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("actDetails")

lblstgDetail.Text = Main.currentStage

End Sub

When i run it the lable to display the lblstgDetails it returns a blank value. Any idea why this is happening?
 

Sagenut

Expert
Licensed User
Longtime User
It should work.
Are you sure that currentStage it's not an empty string?
There are no reference to
stage
As it looks that you are in the beginning..... Consider to switch IMMEDIATELY to B4XPages projects.
Activity projects will only bring you headache and problems.
 
Last edited:
Upvote 0

teddybear

Well-Known Member
Licensed User
hi, I am trying to pass input data (using editText) from main activity and diplay them to a new actity called actDetails.

this a sample of my code:
Main:
Sub Process_Globals
Public currentStage As String
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Main")

currentStage = stage.Text
End Sub

"------------------------------------------------
2nd Activity actDetails

Sub Globals
Private lblstgDetail As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("actDetails")

lblstgDetail.Text = Main.currentStage

End Sub

When i run it the lable to display the lblstgDetails it returns a blank value. Any idea why this is happening?
Please use Code tag to quote your code. and you'd better post a small project.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
It's only so surprisingly simple in B4XPages and with the attached example you can get inspired.

Update: Sorry I had added the B4J version, now added the B4X B4A and B4J version.
 

Attachments

  • B4A_B4J_VariableotherPage.zip
    23.9 KB · Views: 68
Last edited:
Upvote 0

Zizi

Member
It should work.
Are you sure that currentStage it's not an empty string?
There are no reference to
stage
As it looks that you are in the beginning..... Consider to switch IMMEDIATELY to B4XPages projects.
Activity projects will only bring you headache and problems.
stage.text is a edittext from the main activity once you click a "save" button it should pass the data to the actDetails and display it as a label
 
Upvote 0

Zizi

Member
It's only so surprisingly simple in B4XPages and with the attached example you can get inspired.

Update: Sorry I had added the B4J version, now added the B4X B4A and B4J version.
@MicroDrie thanks! i actually need a b4j example beacuse soon I'll be implementing that. unfortunatly for this project I am using default, but I will defiently use B4Xpages for the future, thanks for that advice.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
but I will defiently use B4Xpages for the future
Very good that you choose for that route in the future. Another piece of advice, use the B4X elements as much as possible in your current program. You can then easily reuse your current program solutions in the future with very few adjustments in a future B4XPages solution.
Erel's advice is to develop B4X programs in B4J. My experience is that a B4J program is therefore that it is very simple to convert a B4J program to a B4XPages with very little adjustment.

And regardless of whether or not you program a solution for multiple Operating Systems (OS), working with a B4XPage has many advantages. Because a B4XPage is essentially a class that is stored in a separate file, you can reuse the solution from any B4XPage much more easily. Because you actually cut your program code into different modules that offer a certain functionality.

And if you make an improvement or extension to your B4XPage, that improvement and function extension is immediately applied to all B4XPage programs that are linked to that B4XPage.

Only if you want to release your B4XPages program under a different OS, you will only run into the differences between those OS and you can make an adjustment in your program code to provide a solution for one or more specific OS-related issues. This gives you an unprecedentedly large flexible growth path.

Good luck with your program development.
 
Upvote 0
Top