If i select line in an CustomListView, the CustomListView_ItemClick events fires and the line gets unselected automatically.
But i want to keep the selection visibel.
How is this to do?
Private Sub CustomListView1_ItemClick (Index As Int, Value As Object)
For i = 0 To CustomListView1.Size -1
If i = Index Then
CustomListView1.GetPanel(i).Color = CustomListView1.PressedColor 'Your Selected Color
Else
CustomListView1.GetPanel(i).Color = CustomListView1.DefaultTextBackgroundColor 'Your default Background color
End If
Next
End Sub
This class extends xCustomListView library and adds more selection modes: MODE_SINGLE_ITEM_TEMP - The same as the default behavior. MODE_SINGLE_ITEM_PERMANENT - Single item is selected and the selection remains. MODE_MULTIPLE_ITEMS- Multiple items can be selected. There is also a helper method...
Another way should you like to keep the selection pressed color untill selected again so you can select multi items is to use the ItemLongClick without having to iterate over the items and therefore leave the ItemClick even for something else:
B4X:
Sub Clv1_ItemLongClick (Index As Int, Value As Object)
If clv1.GetPanel(Index).Color= clv1.PressedColor Then
clv1.GetPanel(Index).Color = clv1.DefaultTextBackgroundColor
Else
clv1.GetPanel(Index).Color= clv1.PressedColor
End If
End Sub
Please note that the extended selection in CLVSelections class offers that feature too.