I try to understand how the xCustomListView and the different expanding classes like CLVExpandable or CLVDragger are working. How are you using such libraries and classes. Do you understand or only use the code as it is?
I want to combine both functionalities in one ListView and therefore I should understand what's happening. Perhaps somebody can teach me in depper understanding of Views and Items...
This is the central code of CLVExpandable:
I wrote some ideas as comment between the code. But am I right?
Why can I observe two iterations in Do-Loop of MoveItemBetweenPanels()? If I allow only one, I can see only a gray area. If I allow two all 5 elements are visible immediately.
Why is it so important to first copy all to a temp. View NewPanel and then copy it back to the other temp view p?
How is the structure of a ListView? Okay there are items. And each item contains a object ( a Panel?). But it looks like that the structure is much more complex.
I want to combine both functionalities in one ListView and therefore I should understand what's happening. Perhaps somebody can teach me in depper understanding of Views and Items...
This is the central code of CLVExpandable:
B4X:
Private Sub ResizeItem (Index As Int, Collapse As Boolean)
' this is the item at this place
Dim item As CLVItem = mCLV.GetRawListItem(Index)
' this is the view at this place
Dim p As B4XView = item.Panel.GetView(0)
If p.NumberOfViews = 0 Or (item.Value Is ExpandableItemData) = False Then Return
' create a new similar view
Dim NewPanel As B4XView = xui.CreatePanel("")
MoveItemBetweenPanels(p, NewPanel)
' find out current size
Dim id As ExpandableItemData = item.Value
' why this?
mCLV.sv.ScrollViewInnerPanel.AddView(NewPanel, 0, item.Offset, p.Width, id.ExpandedHeight)
Dim NewSize As Int
If Collapse Then NewSize = id.CollapsedHeight Else NewSize = id.ExpandedHeight
'resize also the item
mCLV.ResizeItem(Index, NewSize)
'why this?
NewPanel.SendToBack
Sleep(mCLV.AnimationDuration)
' why copying it back to p?
If p.Parent.IsInitialized Then ' can the parent be NOT initialized?
MoveItemBetweenPanels(NewPanel, p)
End If
' why this?
NewPanel.RemoveViewFromParent
End Sub
Private Sub MoveItemBetweenPanels (Src As B4XView, Target As B4XView)
Dim i As Int=0
' making a copy of the elements of the view
Do While Src.NumberOfViews > 0
i=i+1
log("Iteration " & i )
Dim v As B4XView = Src.GetView(0)
v.RemoveViewFromParent
Target.AddView(v, v.Left, v.Top, v.Width, v.Height)
Loop
End Sub
I wrote some ideas as comment between the code. But am I right?
Why can I observe two iterations in Do-Loop of MoveItemBetweenPanels()? If I allow only one, I can see only a gray area. If I allow two all 5 elements are visible immediately.
Why is it so important to first copy all to a temp. View NewPanel and then copy it back to the other temp view p?
How is the structure of a ListView? Okay there are items. And each item contains a object ( a Panel?). But it looks like that the structure is much more complex.
Last edited: