B4A Library [Class] Flexible Table

JoséCarlos

Member
Licensed User
File names are for example.
The content of the files can be from your example “citylist_c.csv” with 5 lines.
The return I get in the log is:
(ArrayList) [[Ljava.lang.Object;@3b9a45b3,
[Ljava.lang.Object;@7699a589,
[Ljava.lang.Object;@58372a00,
[Ljava.lang.Object;@4dd8dc3,
[Ljava.lang.Object;@6d03e736
 

klaus

Expert
Licensed User
Longtime User
ISorry, but i am confused here.
You are asking a question about a B4X Class with an example code for B4J !?
So, what exactly do you want to do ?
Why do you want to put the *.csv files into KeystoreValues ?
For me, to be able, to give a concrete advice, i need to understand in detail what your problem is.
 

JoséCarlos

Member
Licensed User
Sorry for the inconvenience of ordering B4J, simply because it's easier!
Thank you very much for your attention and your time.
Hugs.
 

JoséCarlos

Member
Licensed User
I have more than 500 .CSV files, I want to put them all in KVS because it's easier,
that way I'll have to copy only one file to DIRINTERNAL and not more than 500.
 

JoséCarlos

Member
Licensed User
Most 1KB and max 5KB, small files but lots!
KeystoreValues is a SQLite.
The advantage is that I don't have to copy that huge amount of DIRASSETS to DIRINTERNAL every time I do an update!
Yes they are in DIRASSETS and are copied to DIRINTERNAL.
 

Sergey_New

Well-Known Member
Licensed User
Longtime User
Is it possible to add row drag functionality in a table, as done in this class ?
 

Kanne

Member
Licensed User
Longtime User
Most 1KB and max 5KB, small files but lots!
KeystoreValues is a SQLite.
The advantage is that I don't have to copy that huge amount of DIRASSETS to DIRINTERNAL every time I do an update!
Yes they are in DIRASSETS and are copied to DIRINTERNAL.
I don't understand the problem:
if you already have your values stored within a KeyValueStore then it's very simple to transfer them to the table

KeyValueStore to Table:
            Public kvs As KeyValueStore
            kvs.Initialize(DBFileDir, "datastore")
            kvs.put("a", "Test1")
            kvs.put("b", "Test2")
            kvs.put("c", "Test3 1.0")
            kvs.put("c", "Test3 2.0")
            Table1.InitializeTable(2,Gravity.CENTER_HORIZONTAL, False)
            Dim Keys As List = kvs.ListKeys
            For Each Key In Keys
                Dim Wert As Object = kvs.Get(Key)
                Log(Wert)
                Table1.AddRow (Array As String(Key, kvs.Get(Key)))
            Next
 

Kanne

Member
Licensed User
Longtime User
Hi Klaus,
I did not update since a long time but now from V3_21 to V3_30 and have several problems.
It seems, that some routine have a different behavior as before, mostly when changing appearance after filling the table.
Attached an example: if I don't comment these lines I get an empty table whereas in V21 it worked as expected:

SetColumnColors clears table content:
        tableRun.LoadSQLiteDB(SQL1, sQuery.ToString, True)
        tableDes.LoadSQLiteDB(SQL1, sQuery.ToString, True)
        Dim myHeader (tableRun.NumberOfColumns) As String
        Dim myColors (tableRun.NumberOfColumns) As Int
        For i = 0 To myHeader.Length - 1
            myHeader (i) = "Column " & i
            myColors (i) = Colors.Red
        Next
'        tableRun.UseColumnColors = True
'        tableRun.SetColumnColors(myColors)
        tableRun.SetHeader(myHeader)
'        tableDes.UseColumnColors = True
'        tableDes.SetColumnColors(myColors)
        tableDes.SetHeader(myHeader)
 

Attachments

  • 20230331_002512_temp.jpg
    184.3 KB · Views: 162
  • 20230331_002632_temp.jpg
    113.1 KB · Views: 161
  • Test Table.zip
    86.5 KB · Views: 164

Kanne

Member
Licensed User
Longtime User
also I want to change the headings after loading the table - can't get it done in V30
B4X:
        tableRun.UseColumnColors = True
        tableRun.SetColumnColors(myColors)
        tableRun.SetHeaderTextColors(myColors)
        tableRun.SetHeader(myHeader)
I get an empty table ! Disabling the first two line (which should not be necessary) the headercolors are not in correct color.
 

Kanne

Member
Licensed User
Longtime User
it's working now. I already nocticed that the values were still there (by touching a row), so it could also be solved by
B4X:
lbls(i).TextColor = Colors.Black
within the showrow-callback or adding
B4X:
tableRun.SetTextColors(TextColors)

Last question: is it possible that I do not have to call
B4X:
    tableRun.UseColumnColors = True
    tableRun.SetColumnColors(myColors)
when I only want to SetHeaderTextColors ?
 
Last edited:

Kanne

Member
Licensed User
Longtime User
Can you please check the attached new version.
I noticed that the ColumnDataType has been changed but the code seems a bit confusing:
LoadSQLiteDB2() uses the shorts (T/I/R) (example with old long values) and sets cColumnDataType to "TEXT" / "NUMBER",
whereas SetColumnDataType also wants the shorts and setting them to cColumnDataTyp.
So cColumnDataType sometimes has the sort values and sometimes has the long values ?

B4X:
    Dim cColumnDataType() As String
    cColumnDataType = tableRun.GetColumnDataTypes
    Log(cColumnDataType)
    tableRun.SetColumnDataTypes(cColumnDataType)
now pops up a toast "Wrong data type only TEXT abd NUMBER are allowed" ...
 

Kanne

Member
Licensed User
Longtime User
Can you please test this version.
I have improved SetHeaderColors and SetHeaderTextColors.
And changed "TEXT" and "NUMBER" to "T" and "R" or "I".
Hi Klaus,
ColumnDataType seems ok now, I have to change some of my code where I'm calculating the type by myself.
SetHeaderTextColors have still some problem:

if I'm calling it before "NumberOfFixedColumns",
the columns are displayed in wrong color (.NumberOfFixedColumns seems to reset the colors);

if I'm calling it after "NumberOfFixedColumns",
I get a error because cHeaderTextColors is array of 10 (and mNumberOfColumns=10) whereas Header.NumberOfViews is only array of 8 ... so Header.GetView(8) fails !
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…