Android Question [Class] Flexible Table

Sergey_New

Well-Known Member
Licensed User
Longtime User
If possible, how can I change a short press to a long press and vice versa depending on the app settings?
If this isn't possible, what are your suggestions for using the following tapping methods in lists, tables, and the like:
1. Short press - to open the contents of a table row.
2. Long press - to select a row only.
 

klaus

Expert
Licensed User
Longtime User
In the Table class you have the CellClick and the CellLongClick events.
It is up to you to do what you want with each event.
You can check in each event the current settings and execute different code depending on these settings.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
It is up to you to do what you want with each event.
Thanks! I do this for every Activity containing a Table.
I'd like to use a variable from the application to modify the CellClick and CellLongClick events in the class itself.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Sorry, but i do not want to modify the class for specific needs.
The class must remain 'universal'.
But anyway, as you have the source code, feel free to make the modifications for your special requirements.
The source code is open source and you can use it and modify it.
 
Upvote 0

Sergey_New

Well-Known Member
Licensed User
Longtime User
Show me what you have tested
I add the required value (Starter.OneClick) to this code
B4X:
Private Sub InitTable
    Data.Initialize
    If visibleRows.IsInitialized=False Then
        If Starter.OneClick Then
            Cell_Click
        Else
            Cell_LongClick
        End If
    End If
    visibleRows.Initialize
    '...
Perhaps new functions need to be created for Cell_Click and Cell_LongClick, but I don't know how to do that correctly.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
In the Table class you have the Cell_Click Routine and the Cell_LongClick routine.
You should manage the difference in these routines.
B4X:
Private Sub Cell_Click
    Dim rc As RowCol
    Dim L As Label
    L = Sender
    rc = L.Tag

'    SelectRow(rc.Row)
    SelectRow(rc)
    If SubExists(cCallBack, cEventName & "_CellClick") Then
        CallSub3(cCallBack, cEventName & "_CellClick", rc.Col, rc.Row)
    End If
End Sub
Depending on your global variable you could call either
CallSub3(cCallBack, cEventName & "_CellClick", rc.Col, rc.Row)
or
CallSub3(cCallBack, cEventName & "_CellLongClick", rc.Col, rc.Row)
Or any other routine.

And the same in the the other one.
 
Upvote 0
Top