Android Question keep a selection of an CusromListView

HansDieter

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

Alexander Stolte

Expert
Licensed User
Longtime User
How is this to do?
B4X:
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
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
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.
 
Upvote 0
Top