I want that with a Activity.LoadLayout, sub in process finished. In the code below, extract from tutorial of "Different examples with 2 layouts" for TwoActivityLayouts, I add a button1 and Label1 in TwoLayouts1. Button1 write in loop with sleep on Label1. If I click in btnNext1, TwoLayouts2 is load. But when click in btnNext2 and TwoLayouts1 is load, the loop initiated by button1 is still active and writing. There are any way to stop sub in process when you load a new layout?
I test that if I use 2 activities (following the same tutorial) and use Activity.Finish before StartActivity(Layout2) this stop sub, but in fact I have a 4 Layouts with a common code and I prefer (if is possible) not to use several activities. (Following LoadLayoutToPanel example not stop sub)
Thanks
Tutorial: https://www.b4x.com/android/forum/threads/different-examples-with-2-layouts.8416/
LoadLayoutToPanel: https://www.b4x.com/android/forum/threads/how-do-i-unload-a-layout.6993/
I test that if I use 2 activities (following the same tutorial) and use Activity.Finish before StartActivity(Layout2) this stop sub, but in fact I have a 4 Layouts with a common code and I prefer (if is possible) not to use several activities. (Following LoadLayoutToPanel example not stop sub)
Thanks
Tutorial: https://www.b4x.com/android/forum/threads/different-examples-with-2-layouts.8416/
LoadLayoutToPanel: https://www.b4x.com/android/forum/threads/how-do-i-unload-a-layout.6993/
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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.
Dim btnNext1, btnNext2 As Button
Dim edtText1, edtText2 As EditText
Dim rbtTest1, rbtTest2 As RadioButton
Dim Label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("TwoLayouts1")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnNext1_Click
Activity.RemoveAllViews
Activity.LoadLayout("TwoLayouts2")
End Sub
Sub btnNext2_Click
Activity.RemoveAllViews
Activity.LoadLayout("TwoLayouts1")
End Sub
Sub Button1_Click
For i=1 To 30
Label1.Text="Hello"
Sleep(1000)
Label1.Text="World"
Sleep(1000)
Label1.Text="No Stop"
Sleep(1000)
Next
End Sub