Android Question When using the ULV CellLongClick sub SelectionMode is disabled

rleiman

Well-Known Member
Licensed User
Longtime User
Hi everyone,

I have SelectionMode turned on in my Activity_Create sub like this:

B4X:
    ' Set the initial selection mode to single.
    '------------------------------------------
    ULV.SelectionMode = ULV.SELECTION_SINGLE
    ULV.AtLeastOneSelection = False

But when I also use this sub the SelectionMode seems to be disabled. Tapping on the ULV does not show the selected row in the green colour.

B4X:
Sub ULV_CellLongClick(RowID As Long, CellIndex As Byte, Position As Int, ClickedPanel As Panel)
    dbCursor.Position = Position
  
    strCurrentID = dbCursor.GetString("ID")

    StartActivity (StudentDetails)
End Sub

This is how the selection is displayed.

B4X:
Sub Item_RowContentFiller(RowID As Long, LayoutName As String, CellPanel As Panel, CellIndex As Byte, Position As Int)
    If ULV.IsSelected(Position) Then
        'The selected rows are green
        CellPanel.Color = Colors.Green
    Else
        'Alternatively, the rows are coloured in white or in light gray
        If Position Mod 2 = 0 Then
            CellPanel.Color = Colors.White
        Else
            CellPanel.Color = Colors.LightGray
        End If
    End If

    'Reads the data and sets the label text
    Dim lbl As Label = CellPanel.GetView(0) 'The first (and only) view of the cell is a label

    Select CellIndex
        Case 0: dbCursor.Position = Position
            lbl.Text = dbCursor.GetString("StudentSurname")
        Case 1:
            lbl.Text = dbCursor.GetString("StudentForename")
    End Select
End Sub

Is there any way to have both working at the same time?
 
Top