Android Question [SOLVED] B4XTable and map variables

makis_best

Well-Known Member
Licensed User
Longtime User
Hi

I wish someone can point me to right direction.
I want to use in one new project B4XTable post from @Erel in here.
On that post says that we can load values on table as list.
I am going to have my data on map variable.
What is the easiest way to pass all that map values into the table.

Thank you.
 

Mahares

Expert
Licensed User
Longtime User
What is the easiest way to pass all that map values into the table.
Maybe something like this makis. There may be better ways. The data still has to go to a list which then gets added to B4XTable1
See quick example:
B4X:
Dim m As Map = CreateMap("Field1":"apples", "Field2":"orange","Field3":"peaches")
    
    Dim header As List  'use the keys as col names if you want
    header.Initialize
    For Each k As String In m.Keys
        header.Add(k)
    Next
    
    Dim mylist As List
    mylist.Initialize
    Dim r() As String = Array As String(m.Get("Field1"), m.Get("Field2"),m.Get("Field3"))
    mylist.Add(r)
    
    B4XTable1.SetData(mylist)

    'Display data
    For i=0 To mylist.Size-1
        Dim r() As String =mylist.Get(i)
        Log(r(0))
        Log(r(1))
        Log(r(2))
    Next
    
'    Display the field name
    For Each f As String In header
        Log(f)
    Next
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…