0% found this document useful (0 votes)
22 views2 pages

Sliding Tab

The document describes code for a sliding tab application created with B4A. It defines project attributes like supported orientations and external storage permissions. It also defines global variables and activity attributes. The code loads layouts, adds tabs to the tab strip, populates a list view, and includes handlers for tab selection and button/list clicks that display messages.

Uploaded by

Leo Marvis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views2 pages

Sliding Tab

The document describes code for a sliding tab application created with B4A. It defines project attributes like supported orientations and external storage permissions. It also defines global variables and activity attributes. The code loads layouts, adds tabs to the tab strip, populates a list view, and includes handlers for tab selection and button/list clicks that display messages.

Uploaded by

Leo Marvis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

#Region Project Attributes

#ApplicationLabel: B4A Example


#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

#Region Activity Attributes


#FullScreen: False
#IncludeTitle: False
#End Region

#AdditionalJar: com.android.support:support-v4

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Private Button1Page1 As Button


Private Panel1Page2 As Panel
Private ListView1Page3 As ListView
Private TabStrip1 As TabStrip
End Sub

Sub Activity_Create(FirstTime As Boolean)


'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.LoadLayout("Main")

TabStrip1.LoadLayout("Page1", " Home ")


TabStrip1.LoadLayout("Page2", " Image ")
TabStrip1.LoadLayout("Page3", " Lists ")

TabStrip1_PageSelected(0)

ListView1Page3.SingleLineLayout.Label.TextColor = Colors.Black
For i = 1 To 100
ListView1Page3.AddSingleLine($"Item ${i}"$)
Next
End Sub

Sub Activity_Resume

End Sub

file:///D|/Downloads/Sliding%20Tab/Sliding%20Tab%20-%20Copy.txt[04/06/2020 14:47:40]
Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1Page1_Click
Msgbox("Home Tab", "Notice")
End Sub

Sub Panel1Page2_Click
Msgbox("Image Tab", "Notice")
End Sub

Sub ListView1Page3_ItemClick (Position As Int, Value As Object)


Msgbox("Lists Tab" & CRLF & "Your Click Item " & Value , "Notice")
End Sub

Sub TabStrip1_PageSelected (Position As Int)


'Log($"Current page: ${Position}"$)

Dim i As Int
For Each lbl As Label In GetAllTabLabels(TabStrip1)
If i = Position Then
'lbl.SetColorAnimated(200, Colors.Green, Colors.Yellow)
'lbl.Color = Colors.Blue
lbl.TextColor = Colors.RGB(255,255,255)
Else
'lbl.Color = Colors.Blue
lbl.TextColor = Colors.RGB(18,140,126)
End If
i=i+1
Next
End Sub

'--------------------------------------------------------Sub Tab Color-----------------------------------------


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 res As List
res.Initialize
For Each v As View In tc
If v Is Label Then res.Add(v)
Next
Return res
End Sub
'---------------------------------------------------------------------------------------------------------------

file:///D|/Downloads/Sliding%20Tab/Sliding%20Tab%20-%20Copy.txt[04/06/2020 14:47:40]

You might also like