0

I want to save the user's input in Edittext as a global variable so it can be used in other activities. I am using basic4android program. Thanks,

I used this code

First Activity

Sub Process_Globals 'These global variables will be declared once when the application starts. 'These variables can be accessed from all modules.

X = EditText1.text

End Sub

Sub Globals 'These global variables will be redeclared each time the activity is created. 'These variables can only be accessed from this module.

**Private Button1 As Button
Private EditText1 As EditText
Public X As Double**

**Private Label1 As Label**

End Sub

Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: 'Activity.LoadLayout("Layout1") Activity.LoadLayout("enter")

StartActivity("dessert")

End Sub

second acitivity

Sub Globals 'These global variables will be redeclared each time the activity is created. 'These variables can only be accessed from this module.

Private Label1 As Label
Private RadioButton1 As RadioButton

End Sub

Sub Activity_Create(FirstTime As Boolean) 'Do not forget to load the layout file created with the visual designer. For example: 'Activity.LoadLayout("Layout1") Activity.LoadLayout("dessert")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub RadioButton1_CheckedChange(Checked As Boolean)

Label1.text= X

I want to show the value of variable X in the label End Sub

but it says the variable X is not declared and I already declared it in the first acitivity How to fix it ?

Rim
  • 11
  • 3

1 Answers1

0

Its not an answer. Its an idea. Use Shared Preference or sqlite db to store a value. And you can call and get it from other activities.

Indra Kumar S
  • 2,818
  • 2
  • 16
  • 27