B4J Question Accordion set height to individual tabs

walterf25

Expert
Licensed User
Longtime User
Hi all, i recently asked another question similar to this one, HERE although i thought i had gotten the answer i needed, i'am now facing another issue.

I have an accordion object with 10 different tabs, the issue i'am now having is that i would like to set the height of each tab according to the content of the layout of each tab. as you guys can see in the image, the first tab's height is perfect for the first layout, but on the second tab there is a white space below the layout, which i would like to find out how to get rid of.
tab1.jpg



tab2.jpg


Does anyone have any idea or suggestions on how to accomplish this, you guys can see Erel's answer on the thread i posted above, although that works on the first layout, it doesn't work on the second layout for the second tab, i would like to set the height of each tab automatically so that it resizes according to the content.

Thanks and Regards,
walter
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi!
Without actually testing it, have you tried?

B4X:
    Dim g As Accordion 
    Dim p As Pane = g.Panes.Get(0)
    p.PrefHeight = 250 ' the dynamic value you are trying to achieve
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Hi!
Without actually testing it, have you tried?

B4X:
    Dim g As Accordion
    Dim p As Pane = g.Panes.Get(0)
    p.PrefHeight = 250 ' the dynamic value you are trying to achieve
I tried it but i get an error, which makes sense because the Accordion object uses a TiledPane rather than a Pane.

I found some javaObject code and set the PrefHeight using the following code

B4X:
Sub asJavaObject(j As JavaObject) As JavaObject
    Return j
End Sub

B4X:
Sub Accordion1_PaneChanged (ExpandedPane As TitledPane)
    If ExpandedPane.IsInitialized Then
        Log("Current Pane: " & ExpandedPane.Text)
    If ExpandedPane.Text = "Mechanical Visual Inspection" Then
    asJavaObject(ExpandedPane).RunMethod("setPrefHeight", Array(50.00))
     Log("prefheight: " & asJavaObject(ExpandedPane).RunMethod("getPrefHeight", Null))         
    End If
    End If
End Sub
then in the "Sub Accordion1_PaneChanged (ExpandedPane As TitledPane)" i pass the expandedPane as a parameter to the JavaObject to set the PrefHeight, the problem is that while i don't get any errors and as far as I can tell the code works fine but i don't see the tiledpane being resized to the height being specified.

Any other suggestions are welcomed.

Thanks,
Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
The height of each item is the same. It is the Accordion height - the height of all titles.

You can try to change the accordion height based on the selected pane though it will probably won't be smooth
Hi Erel, according to this post here, the titled pane is supposed to automatically resize to accommodate the preferred size of its content.

I also see that there is another class called gridpane that can maybe help with this issue?

Regards,
Walter
 
Upvote 0
Top