CLV1.ScrollToItem(CLV1.Size-1)
Dim e As ExpandableItemData = CLV1.GetValue(CLV1.Size-1)
If e.Expanded = False Then 'check if item is expanded
CLVExpandable1.ToggleItem(CLV1.Size-1)
End If
CLV1.ScrollToItem(CLV1.Size-1)
Dim e As ExpandableItemData = CLV1.GetValue(CLV1.Size-1)
If e.Expanded = False Then 'check if item is expanded
CLVExpandable1.ToggleItem(CLV1.Size-1)
End If
CLV1.ScrollToItem(CLV1.Size-1)
If Not(CLV1.GetValue(CLV1.Size-1).As(ExpandableItemData).Expanded) Then 'check if item is expanded
CLVExpandable1.ToggleItem(CLV1.Size-1)
End If
It was required to add a Sleep(5) for a long list. Sleep(0) is small.
B4X:
Sub ExpandToItem(index As Int)
If CLV1.Size = 0 Then Return
CLV1.ScrollToItem(index)
Sleep(5)
Dim e As ExpandableItemData = CLV1.GetValue(index)
If e.Expanded = False Then
CLVExpandable1.ToggleItem(index)
End If
End Sub
Sub ExpandToItem(index As Int)
If index < 0 Then Return 'items is 0 to n
CLV1.ScrollToItem(index)
Sleep(CLV1.AnimationDuration) 'test sleep
Dim e As ExpandableItemData = CLV1.GetValue(index)
If e.Expanded = False Then
CLVExpandable1.ToggleItem(index)
End If
End Sub
Sub ExpandToItem(index As Int)
If CLV1.Size = 0 Then Return
CLV1.ScrollToItem(index)
Sleep(5)
Dim e As ExpandableItemData = CLV1.GetValue(index)
If e.Expanded = False Then
CLVExpandable1.ToggleItem(index)
End If
End Sub
Why not simply have the below code and get the same result:
B4X:
Sub ExpandToItem(index As Int)
CLVExpandable1.ExpandItem(index) 'works to expand the given item
Sleep(5)
clv1.ScrollToItem(index )
End Sub
Have you tried to use the value to expand by instead of index. The index is abstract. You don;t usually know what is strored there. . Here it is. It works for me in B4A and B4J. You can adjust you sleep time and shuffle lines of code if it suits:
B4X:
ExpandToItem("mosc")
B4X:
Sub ExpandToItem(val As String)
For i = 0 To clv1.Size -1
Dim e As ExpandableItemData = clv1.GetValue(i)
Dim s As String =e.Value
If s.tolowercase.Contains(val.tolowercase) Then
Sleep(0)
clv1.ScrollToItem(i)
Expandable.ExpandItem(i)
Return
End If
Next
End Sub