Using the awesome library found here: https://www.b4x.com/android/forum/threads/b4x-b4xtable-multiple-rows-selection.102364/
I know there is probably a simple solution, but I can't quite figure it out. Is there a way to convert the example above to select only one row, but still deselect on second press?
Essentially, I only want to allow 1 row to be highlighted at 1 time, I want to unhighlight (deselect) it on a cell_click if it is already highlighted (selected).
In the code snippets found below, you will find that I have it acting as I should, except it is not unhighlighting (deselecting) rows.
I feel like I am missing something that should be obvious, so any help would be greatly appreciated. Thanks!
My Globals:
My CellClicked:
My SetRowColor:
I know there is probably a simple solution, but I can't quite figure it out. Is there a way to convert the example above to select only one row, but still deselect on second press?
Essentially, I only want to allow 1 row to be highlighted at 1 time, I want to unhighlight (deselect) it on a cell_click if it is already highlighted (selected).
In the code snippets found below, you will find that I have it acting as I should, except it is not unhighlighting (deselecting) rows.
I feel like I am missing something that should be obvious, so any help would be greatly appreciated. Thanks!
My Globals:
B4X:
Dim sRow As Int = 0
Dim pRow As Int = 0
My CellClicked:
B4X:
Sub B4XRegister_CellClicked(ColumnId As String, RowId As Long)
If pRow = RowId Then
sRow = -1
pRow = -1
Dim Index As Int = B4XRegister.VisibleRowIds.IndexOf(RowId)
SetRowColor(Index, False)
Else
sRow = RowId
pRow = RowId
Dim Index As Int = B4XRegister.VisibleRowIds.IndexOf(RowId)
SetRowColor(Index, True)
End If
End Sub
My SetRowColor:
B4X:
Sub SetRowColor(RowIndex As Int, Selected As Boolean)
Dim clr As Int
If Selected Then
clr = SelectionColor
Else
If RowIndex Mod 2 = 0 Then
clr = B4XRegister.EvenRowColor
Else
clr = B4XRegister.OddRowColor
End If
End If
For Each c As B4XTableColumn In B4XRegister.VisibleColumns
Dim pnl As B4XView = c.CellsLayouts.Get(RowIndex + 1) '+1 because of the header
pnl.Color = clr
Next
End Sub