I have a questoin regarding the best way to keep a common layout properties the same between all pages inside a tab bar controller.
The layout PostAs needs to be the same in mapPage and listPage, and needs to stay synced between them. In the code below I make a copy of pnlContainerPostAs with pnlContainerPostAsListPage for the list page and then I plan to copy the views/properties when the mapPage/ListPage Appear event is fired. Is this the best way to handle it?
The layout PostAs needs to be the same in mapPage and listPage, and needs to stay synced between them. In the code below I make a copy of pnlContainerPostAs with pnlContainerPostAsListPage for the list page and then I plan to copy the views/properties when the mapPage/ListPage Appear event is fired. Is this the best way to handle it?
B4X:
'Code module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Private App As Application
Private mapPage, listPage As Page
Dim map As GoogleMap
Private pnlView, pnlMap, pnlClv As Panel
Private lblTitle As Label
Private pnlContainerPostAs, pnlContainerPostAsListPage As Panel
Private clv_postAs, clv_postAsListPage As CustomListView
Private btnPostAsCancel As Button
Private lblPostAs As Label
End Sub
Sub show
If Global.PageHeight = -1 Then Global.PageHeight = 100%y
If Global.PageWidth = -1 Then Global.PageWidth = 100%x
mapPage.Initialize("mapPage")
listPage.Initialize("listPage")
listPage.RootPanel.LoadLayout("logeneral")
listPage.RootPanel.LoadLayout("lomap")
pnlClv = pnlView
pnlClv.LoadLayout("loclv")
listPage.RootPanel.LoadLayout("loPostAs")
pnlContainerPostAsListPage = pnlContainerPostAs
lblTitle.Text = "List"
lblPostAs.Text = "Explore by"
mapPage.RootPanel.LoadLayout("logeneral")
mapPage.RootPanel.LoadLayout("lomap")
pnlMap = pnlView
pnlMap.LoadLayout("lomap2")
mapPage.RootPanel.LoadLayout("loPostAs")
lblTitle.Text = "Map"
lblPostAs.Text = "Explore by"
Global.SetPageTitle(mapPage, "Map View")
Global.SetPageTitle(listPage, "List View")
Global.AddTabBarController("tc",App,Array(mapPage, listPage), 0)
Global.resetDefaultHeights
'Global.hd.ProgressDialogShow("Loading...")
getDetails
map.Initialize("map","AIzaSyCaLtZdyg3DCQ8OuvdO7pIA7m9TSaKYyHk")
pnlMap.AddView(map, 0,0,pnlMap.width,pnlMap.Height)
map.MyLocationEnabled = True
map.GetUiSettings.CompassEnabled = True
map.GetUiSettings.MyLocationButtonEnabled = True
End Sub
Sub listPage_Appear
If Global.TabController.SelectedIndex == 1 Then
For Each v As View In pnlContainerPostAs.GetAllViewsRecursive
pnlContainerPostAsListPage.AddView(v, v.Left, v.Top,v.Width, v.Height)
Next
End If
End Sub
Sub mapPage_Appear
'Vise versa of listpage
For Each v As View In pnlContainerPostAsListPage.GetAllViewsRecursive
pnlContainerPostAs.AddView(v, v.Left, v.Top,v.Width, v.Height)
Next
End If
End Sub
Sub getDetails
End Sub
Sub btnBack_Click
Global.doBack(0)
End Sub
Sub ivCategory_Click
If Global.TabController.SelectedIndex = 0 Then
Global.showpostaspnl(pnlContainerPostAs, clv_postAs, btnPostAsCancel)
Else
Global.showpostaspnl(pnlContainerPostAsListPage, clv_postAsListPage, btnPostAsCancel)
End If
End Sub
Sub btnPostAsCancel_Click
If Global.TabController.SelectedIndex = 0 Then
Global.hidepostaspnl(pnlContainerPostAs)
Else
Global.hidepostaspnl(pnlContainerPostAsListPage)
End If
End Sub