Sub Globals
Private clv1 As CustomListView
Private lblTitle As B4XView
Private pnlTitle As B4XView
Private pnlExpanded As B4XView
Private xui As XUI
Private expandable As CLVExpandable
Private prevIndex As Int '<== added this
End Sub
Now in the clv1_ItemClick event handler:
B4X:
Sub clv1_ItemClick(Index As Int, Value As Object)
If prevIndex >= 0 Then
expandable.CollapseItem(prevIndex)
End If
expandable.ExpandItem(Index)
prevIndex = Index
End Sub
Problem: touching an item for the first time, expands it. Touching the same item again, collapses it, but touching the same item again, does not expand it.
I've searched the forum for a solution, but nothing.
Tracking state is difficult. Go with the simpler option:
B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)
For i = 0 To clv1.Size - 1
If i = Index Then Continue
Dim e As ExpandableItemData = clv1.GetValue(i)
If e.Expanded Then
expandable.CollapseItem(i)
Sleep(clv1.AnimationDuration)
End If
Next
expandable.ToggleItem(Index)
End Sub