B4J Tutorial TabPane Example

SS-2016-01-07_08.27.05.png


The TabPane container allows the user to switch between different tab pages.

Working with TabPane is similar to working with SplitPane. Each page is made of a different layout file.
The most important point is to use anchors in the pages layouts. This way the layouts will be resized automatically when the TabPane is resized.

For example the following code adds two pages. The second parameter is the tab title.
Tab1 and Tab2 are layout files.
B4X:
Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.SetFormStyle("UNIFIED")
   MainForm.RootPane.LoadLayout("Main")
   TabPane1.LoadLayout("Tab1", "Tab 1")
   TabPane1.LoadLayout("Tab2", "Tab 2")
   MainForm.Show
End Sub

TabPane.LoadLayout returns a TabPage object. You can use this object to further configure the page.

The example is attached.
 

Attachments

  • TabPane.zip
    6.8 KB · Views: 1,993
Last edited:

StarinschiAndrei

Active Member
Licensed User
Longtime User
Hello,
Is it possible to add close button in tab? something like in attached image, if yes how can i handle the close tab event.
Thank you.
 

Attachments

  • TabWithCloseButton.png
    TabWithCloseButton.png
    2.2 KB · Views: 490
Top