B4J Question [SOLVED] TabPane opened step-by-step with Buttons - How to?

JOTHA

Well-Known Member
Licensed User
Longtime User
Hello community,

i have an example with 3 Tabs, but i don't want to open all Tabs at once.
They should be opened step-by-step with a Button_Click (forwards and backwards).

The problem is that the Tabs are opened more than one time, so i have several times opened Tab1 ...
How can i prevent the Tabs opening for more than one time (once)?
Attached is an example ...
 

Attachments

  • TabPane_with_Buttons.zip
    4.7 KB · Views: 172

Daestrum

Expert
Licensed User
Longtime User
try this - (although personally I would add all the tabs before displaying tabpane and just have 2 buttons forward and back - with back disabled on first page and forward disabled on last page)

B4X:
Sub Process_Globals
 Private fx As JFX
 Private MainForm As Form
 Private TabPane1 As TabPane
 
 Private Button1 As Button
 Private Button2 As Button
 Private Button3 As Button
 Private Pane1 As Pane
 Private Pane2 As Pane
 Private Shown1,Shown2,Shown3 As Boolean  ' <<<<<<<<<<<<<<< new bit
End Sub
Sub AppStart (Form1 As Form, Args() As String)
 MainForm = Form1
 MainForm.RootPane.LoadLayout("1")
 MainForm.Show
 MainForm.Stylesheets.Add(File.GetUri(File.DirAssets, "TabPane.css"))
 TabPane1.LoadLayout("2", "Tab 1")
 Shown1=True
End Sub
Sub Button1_Click  'forward to Tab 2
 If Shown2=False Then
  TabPane1.LoadLayout("3", "Tab 2")
  Shown2=True
 End If
 TabPane1.SelectedIndex = 1
End Sub
Sub Button2_Click  'back to previous
 If Shown1=False Then 
  TabPane1.LoadLayout("2", "Tab 1")
  Shown1=True
 End If
 TabPane1.SelectedIndex = TabPane1.SelectedIndex - 1
End Sub
Sub Button3_Click  'forward to Tab 3
 If Shown3=False Then
  TabPane1.LoadLayout("3", "Tab 3")
  Shown3=True
 End If
 TabPane1.SelectedIndex = 2
End Sub
 
Upvote 0

JOTHA

Well-Known Member
Licensed User
Longtime User
Hi Daestrum,

thank you very much for your help!
I made a B4J - TabPane with 6 Tabs and "Forward- + Backward-Buttons" for those who find this usefull (see attachment).
 

Attachments

  • TabPane_with_6_Tabs_and_Forward_Backward_Buttons.zip
    10 KB · Views: 193
Upvote 0
Top