Other Help, Activity recharges when rotating screen

rscheel

Well-Known Member
Licensed User
Longtime User
Hello, I need help with this, as it says in the title, the application is reloaded by rotating the screen, is there any way to control this so that when you rotate the screen does not recharge.

If I could provide some sample code.

Thank you.

@Erel
 

rscheel

Well-Known Member
Licensed User
Longtime User
Sorry, but do not quite understand, the operation of this.
For example I have my code in this I have buttons and a EditText.
I would like to prove that by rotating the writing on the box is maintained.

Here is the code.

B4X:
Sub Process_Globals
  
End Sub

Sub Globals
    Private ScrollView1 As ScrollView
    Private Button1 As Button
    Private Button2 As Button
    Private Button3 As Button
    Private Button4 As Button
    Private EditText1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Activity.LoadLayout("LayoutHome")
    ScrollView1.Initialize(500dip)
    Activity.AddView(ScrollView1, 0, 0, 100%x, 100%y)
    ScrollView1.Panel.LoadLayout("LayoutHome")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

I feel so hardheaded, but the only thing that I could achieve better since people started with B4A.
 
Upvote 0

eurojam

Well-Known Member
Licensed User
Longtime User
this is a very simple example, where the edittext is stored in a process_global and restored in the activity resume (there are better solutions, I am sure...)
B4X:
Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Private mytxt As String
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 etxt As EditText
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")
    etxt.Initialize("etxt")
    Activity.AddView(etxt, 0dip,100dip, 100dip,100dip)

End Sub
Sub     etxt_TextChanged (Old As String, New As String)
    mytxt = New
End Sub

Sub Activity_Resume
If mytxt <> "" Then
     etxt.Text = mytxt
End If
End Sub
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…