When i rotate my device the layout vanishes. The only way i can retain it is if i have this in the Activity_Resume sub
B4X:
Sub Activity_Resume
Activity.LoadLayout("Menu")
End Sub
Surely this is not right?
This is the Create Sub
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime=True Then
Activity.LoadLayout("Menu")
SQL.Initialize(File.DirDefaultExternal, "WDOrders.db", True)
Activity.LoadLayout("Table")
WebView1.Width = 100%x - WebView1.Left
WebView1.Height = 90%y - WebView1.Top
Image1.Initialize("Image1")
Image1.Visible = False
Activity.AddView(Image1, 10dip, 10dip, 100%x - 20dip, 100%y - 20dip)
WebView1.Visible=False
End If
End Sub
FirstTime is true when the process is created. Later your activity can be recreated many times and FirstTime will be false.
Layout related code should always run:
B4X:
Sub Activity_Create(FirstTime As Boolean)
If FirstTime=True Then
SQL.Initialize(File.DirDefaultExternal, "WDOrders.db", True)
End If
Activity.LoadLayout("Menu")
Activity.LoadLayout("Table")
WebView1.Width = 100%x - WebView1.Left
WebView1.Height = 90%y - WebView1.Top
Image1.Initialize("Image1")
Image1.Visible = False
Activity.AddView(Image1, 10dip, 10dip, 100%x - 20dip, 100%y - 20dip)
WebView1.Visible=False
End Sub