B4J Question Problems with a CLV in an Expandable CLV

GuyBooth

Active Member
Licensed User
Longtime 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

  • Expandable CLV Color Problem.zip
    5.3 KB · Views: 172
  • CLV1_Item 2 10 Rows of 20 showing after 1st click, space for scroll bar but no bar showing.PNG
    CLV1_Item 2 10 Rows of 20 showing after 1st click, space for scroll bar but no bar showing.PNG
    177.7 KB · Views: 222
  • CLV1_Item 2 10 Rows of 20 showing after 3rd click, no space for scroll bar, no bar showing.PNG
    CLV1_Item 2 10 Rows of 20 showing after 3rd click, no space for scroll bar, no bar showing.PNG
    174.1 KB · Views: 217
  • CLV1_Item 199 10 Rows of 20 showing with scroll bar as expected.PNG
    CLV1_Item 199 10 Rows of 20 showing with scroll bar as expected.PNG
    177.1 KB · Views: 251
  • CLV1_Item 199 only 1 Row of 10 showing.PNG
    CLV1_Item 199 only 1 Row of 10 showing.PNG
    63.9 KB · Views: 186
  • CLV1_Item 200 10 Rows of 20 showing with scroll bar as expected.PNG
    CLV1_Item 200 10 Rows of 20 showing with scroll bar as expected.PNG
    179.9 KB · Views: 217

GuyBooth

Active Member
Licensed User
Longtime 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

  • CLV1 Item 200 expanded as it does - wrongly - look.PNG
    CLV1 Item 200 expanded as it does - wrongly - look.PNG
    44.5 KB · Views: 176
  • CLV1 Item 200 expanded as it should look.PNG
    CLV1 Item 200 expanded as it should look.PNG
    173.4 KB · Views: 185
  • B4J Expandable clv problems 2.zip
    123.4 KB · Views: 183
Upvote 0
Top