B4J Tutorial Accordion container

accordion.gif


The Accordion container (added in B4J v5.0) is a container similar to TabPane. It holds TitledPanes. These are panes with titles.

Using the accordion is quite simple. Add the Accordion node with the designer and create a layout file for each of the TitledPanes.

B4X:
Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("Main")
   Accordion1.LoadLayout("Pane1", "Pane 1")
   Accordion1.LoadLayout("Pane2", "Pane 2")
   Accordion1.LoadLayout("Pane3", "Pane 3")
   MainForm.Show
End Sub

It is recommended to use anchors in the layouts so the layout will be resized automatically based on the available size.
 

Attachments

  • AccordionExample.zip
    5.1 KB · Views: 1,426

Cableguy

Expert
Licensed User
Longtime User
Can the TitledPanes Titles be set using other methods than the LoadLayout?
I would like to preate the TitledPanes in code, and add view to the panes in code.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I would like to preate the TitledPanes in code, and add view to the panes in code.
This is a mistake in most cases.

You can create an empty layout and load it whenever you need. You can also create a layout file with some of the views, load it and add the "dynamic" views programmatically.
 
Top