B4J Question Problems with a CLV in an Expandable CLV

GuyBooth

Active Member
Licensed User
In the attached project, the code has been adapted from the Expandable CLV Erel posted on the forum.

When the arrow on an expandable item is clicked, the expansion panel opens with another clv containing TextItems. The goal is that if the new clv only contains a few items, it will fit neatly between two items in the parent CLV. If it contains, say, 20 items, its height will be limited so it can be fully visible between two items in the parent, and have its own scroll bars to allow the user to scroll through the child items.

The essential code is in the clExpclv class module, the dtmm_Schemes is only used for setup of colors.

I am seeing these problems:
When I click on any of the parent items except the bottom two, the child opens and loads, and there is a space on the right of the text items where the Scrollbar should be - but no scrollbar is visible. Clicking on the arrow to close it, then clicking again to reopen it shows the same child items (as it should) but this time there is no scrollbar and the space for the scrollbar has disappeared. The user can still scroll through the child items by using the mouse wheel.

When I click on either the bottom item or the bottom but one, I see the child items loaded properly with the scrollbar present. However, clicking and clicking again on this item is unpredictable - sometimes I see the item fully loaded but into the space a single item normally fills, other times it will fill all the space as it should.

The screenshots I have uploaded show some of these results.
Been working on this for a while with different compinations in my code and I feel as though I almost have it - but sadly not there yet.
It's would be a pretty powerful combination if it could be made to work.
Would appreciate it if someone could look at this and see if there is a solution.
 

Attachments

Erel

Administrator
Staff member
Licensed User
You can uncheck the "Show Scroll Bar" option for the internal CLV.

I've checked the project you've uploaded. You should make the background of the Item layout and clv1 transparent.
 

GuyBooth

Active Member
Licensed User
After working around this I found the "inner" scrollbar hidden underneath the "outer" one. So I've cleaned up the code and brought it to a point where I get good results, and it all works except for under one circumstance, which in the previous version was sporadic but in this version is repeatable.
That is the situation when I click on the arrow button for the bottom item, the CLV opens into a single scrollable line holding all 20 items.

The problem appears to show up in this code:
B4X:
Private Sub MoveItemBetweenPanels (Src As B4XView, Target As B4XView)
'    This was the original code in the example in the forum
    Do While Src.NumberOfViews > 0
        Dim v As B4XView = Src.GetView(0)
        v.RemoveViewFromParent
        Target.AddView(v, v.Left, v.Top, v.Width, v.Height)
'' This doesn't look right - for the last item in the mCLV the v.height is 33, but clicking on all the other items yields 628.
Log($"v.height: ${v.height}"$)
    Loop
End Sub
It seems to be something relating to and extra layer of panel? The following code cures the problem, but I'm not comfortable with it because I don't think it is the correct solution:
B4X:
Private Sub MoveItemBetweenPanels (Src As B4XView, Target As B4XView)
'' This works but I don't know why:
    Do While Src.NumberOfViews > 0
        Dim v As B4XView = Src.GetView(0)
        Dim v1 As B4XView = Src.GetView(0).GetView(0)
        v.RemoveViewFromParent
        Target.AddView(v, v.Left, v.top, v.Width, v1.height)
    Loop
End Sub
Any further thoughts? I seem to be so close to making this work - but not quite there!
 

Attachments

Erel

Administrator
Staff member
Licensed User
It is a mistake to modify CLVExpandable class unless you think that there is a bug in the class code. All other features that you want to add should be implemented in different modules.

If you can reproduce it with the standard CLVExpandable then I can check it.
 
Top