Android Question [B4X] How do I load separate code with each TabStripView Page?

Joey249

Member
So i've configured my app already and then later on decided I wanted to use TabStripViewPager,

The issue i'm having is i've all my code on separate pages for separate layouts, and i'm not quite sure how to load in that code/module with each TabStrip layout.

For example, with the TabStrip it loads in like this
B4X:
Private TabStrip1 As TabStrip
TabStrip1.LoadLayout("LAYOUTNAME", "Title for layout")

while on other pages I have previously loaded it in like
B4X:
Dim Page1 As Page1MODULECODE
Page1.Initialize
B4XPages.AddPage("LAYOUTNAME", Page1)
B4XPages.ShowPage("LAYOUTNAME")

where "LAYOUTNAME" would be connected to the code on "Page1 "/ "Page1MODULECODE",
is there any way to link in the code like this with the TabStrip as it would be a bit messy having all the code from all TabStrip layouts in one page, any help would be greatly appreciated!
 
Solution
Create a class for each tab page. It will NOT be a B4XPage class.

Create a layout with a single panel that is anchored to all sides. Use it for each tab page:
B4X:
TabStrip1.LoadLayout("LAYOUT_WITH_PANEL", "Title for layout 1")
Dim tab1 As Tab1Class
tab1.Initialize(PanelFromLayout)
TabStrip1.LoadLayout("LAYOUT_WITH_PANEL", "Title for layout 2")
Dim tab2 As Tab2Class
tab2.Initialize(PanelFromLayout)

Erel

B4X founder
Staff member
Licensed User
Longtime User
Create a class for each tab page. It will NOT be a B4XPage class.

Create a layout with a single panel that is anchored to all sides. Use it for each tab page:
B4X:
TabStrip1.LoadLayout("LAYOUT_WITH_PANEL", "Title for layout 1")
Dim tab1 As Tab1Class
tab1.Initialize(PanelFromLayout)
TabStrip1.LoadLayout("LAYOUT_WITH_PANEL", "Title for layout 2")
Dim tab2 As Tab2Class
tab2.Initialize(PanelFromLayout)
 
Upvote 1
Solution

Joey249

Member
Create a class for each tab page. It will NOT be a B4XPage class.

Create a layout with a single panel that is anchored to all sides. Use it for each tab page:
B4X:
TabStrip1.LoadLayout("LAYOUT_WITH_PANEL", "Title for layout 1")
Dim tab1 As Tab1Class
tab1.Initialize(PanelFromLayout)
TabStrip1.LoadLayout("LAYOUT_WITH_PANEL", "Title for layout 2")
Dim tab2 As Tab2Class
tab2.Initialize(PanelFromLayout)
Worked perfectly, thank you Erel!
 
Upvote 0
Top