Hello, i 'm trying to make a TabStripViewPager with views taken from a class. I wanted like this because is more elegant code and also, i need to use only 1 form and loaded to every tab with different data. So made the code bellow.
In the form there are a label and a CLV.
The problem is that i can see only the last form and nothing else.
I tried to make different .bal files for every form without result.
So i you please have a look to my code to tell me your opinion i'll be grateful.
In the form there are a label and a CLV.
The problem is that i can see only the last form and nothing else.
I tried to make different .bal files for every form without result.
So i you please have a look to my code to tell me your opinion i'll be grateful.
Class TabStrip:
Sub Class_Globals
Public xui As XUI
Public Root As B4XView
'Public
Public label1 As Label
Public panel1 As Panel
Public CustomListView1 As CustomListView
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Parent As B4XView)
Root = Parent
End Sub
Public Sub loadLayout(pos As Int) As String
Dim p As Panel
p.Initialize("")
Root.AddView(p, 0, 10%y, 100%x, 100%y)
p.LoadLayout("frm"&pos)
Return("frm"&pos)
' Return("frm0")
End Sub
Public Sub getPanel As B4XView
Return panel1
End Sub
Public Sub loadCLV(pos As Int)
CustomListView1.Clear
For i = 0 To 30 Step pos+1
CustomListView1.AddTextItem($"Item #${i}"$, "")
Next
End Sub
Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
End Sub
B4XMainPage:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private tabstrip1 As TabStrip
Private myTabs(3) As tabStribs
Private Panel1 As Panel
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
For i = 0 To myTabs.Length-1
myTabs(i).Initialize(Root)
Next
For i = 0 To myTabs.Length-1
tabstrip1.LoadLayout(myTabs(i).loadLayout(i), "Page"&i)
myTabs(i).label1.text = "Page " & i
myTabs(i).panel1.Color = xui.Color_RGB(150+10*i,100+10*i,10+10*i)
myTabs(i).loadCLV(i)
Next
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Sub TabStrip1_PageSelected (Position As Int)
Log($"Current page: ${Position}"$)
myTabs(Position).label1.text = "Page " & Position
myTabs(Position).panel1.Color = xui.Color_RGB(150+10*Position,100+10*Position,10+10*Position)
myTabs(Position).loadCLV(Position)
End Sub