I've been trying to get the name of the current selected tab each time the user switches tabs. But the code below results in a crash:
And this is the way I add my tabs:
B4X:
Sub TabStrip1_PageSelected (Position As Int)
Log(GetCurrentPageTabText(TabStrip1))
End Sub
And this is the way I add my tabs:
B4X:
TabStrip1.LoadLayout("1","First")
TabStrip1.LoadLayout("2","Second")
TabStrip1.LoadLayout("3","Third")
B4X:
Sub GetCurrentPageTabText(tb As TabStrip) As String
Dim lbl As Label = GetAllTabLabels(tb).Get(tb.CurrentPage)
Return lbl.Text
End Sub
Public Sub GetAllTabLabels (tabstrip As TabStrip) As List
Dim jo As JavaObject = tabstrip
Dim r As Reflector
r.Target = jo.GetField("tabStrip")
Dim tc As Panel = r.GetField("tabsContainer")
Dim resd As List
resd.Initialize
For Each v As View In tc
If v Is Label Then resd.Add(v)
Next
Return res
End Sub
Last edited: