Android Question Can you Use a Map Values to Execute B4XTable Functions

Mahares

Expert
Licensed User
Longtime User
I use this code to create the map:
B4X:
m = CreateMap("Frozen cols = 1": "B4XTable1.NumberOfFrozenColumns = 1", "EvenRowColor": _
"B4XTable1.EvenRowColor = xui.Color_Cyan", _
"OddRowColor": "B4XTable1.OddRowColor = xui.Color_Yellow")
Log(Settings(m.get("EvenRowColor")))
The function is obviously output to the log, but I can't figure out how to actually execute the function B4XTable1.EvenRowColor = xui.Color_Cyan by extracting the value from the map.
B4X:
Sub Settings(s As String) As String
     Return s
End Sub
Thank you
 

aeric

Expert
Licensed User
Longtime User
B4X:
Private Sub InitializeSettings As Map
    Dim m As Map = CreateMap( _
    "NumberOfFrozenColumns": 1, _
    "EvenRowColor": xui.Color_Cyan, _
    "OddRowColor": xui.Color_Yellow)
    Return m
End Sub

Private Sub LoadSettings (TableSettings As Map)
    For Each Key In TableSettings.Keys
        Dim Value As Object = TableSettings.Get(Key)
        Log($"${Key} = ${Value}"$)
        Select Key
            Case "NumberOfFrozenColumns"
                B4XTable1.NumberOfFrozenColumns = Value
            Case "EvenRowColor"
                B4XTable1.EvenRowColor = Value
            Case "OddRowColor"
                B4XTable1.OddRowColor = Value
        End Select
    Next
End Sub

To call:
B4X:
Dim s As Map = InitializeSettings
LoadSettings(s)

I wrote in B4J but I think it works in B4A.
 

Attachments

  • B4XTableExample.zip
    234.9 KB · Views: 54
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…