Android Question Trying to fill a tableview with DBUtils.ExecuteMemoryTable

GeoffT660

Active Member
Licensed User
Longtime User
Can someone post a little code on filling a table created with the tableview class with the DBUtils.ExecuteMemoryTable Function or direct me to a previous post. I can display it fine from a .csv file but cannot figure how to load directly from a SQLLite Table.
 

GeoffT660

Active Member
Licensed User
Longtime User
What tableview class are you speaking of ?
In the Flexibe Table class you have a function to read a SQLite table directly into the table.
Thanks so much for your quick response. I will have to check into it. I was using the version 1.13 that has the TableExample Example. I didn't realize there we so many variations.
 
Upvote 0

Devan

Member
Licensed User
Longtime User
Hi Geoff,
Can you pls share code how to Export SQL into Flexible Table and show it on device.
I have been trying but dont know how to do it
Thank you
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Can you pls share code how to Export SQL into Flexible Table and show it on device.
See Post #2. Use the flexible Table class.
 
Upvote 0

Devan

Member
Licensed User
Longtime User
Hi DonManfred, Hope you are fine.
Just want to clarify, is it sufficient enough just use the Sub LoadSQLiteDB to show the table or do I need to Create Panel on designer to Populate the table.
Thank you.
 
Upvote 0

Devan

Member
Licensed User
Longtime User
Hi Mr.Klaus,
Good Day to you. I copied the code from Table1.43
As below. Now I'm getting error at Line 299 in Module Class Table at SelectedRows.Initialize. Any idea why?
Thank you.
B4X:
    Panel3Reports.Visible = True
    Dim Query As String
   
    Table1.ClearAll

    Table1.LineWidth = 3dip
    Table1.TextSize = 20

    Dim tf() As Typeface
    tf = Array As Typeface(Typeface.DEFAULT, Typeface.DEFAULT_BOLD, Typeface.DEFAULT, Typeface.DEFAULT_BOLD, Typeface.DEFAULT)
    Table1.SetTypeFaces(tf)

    Table1.UseColumnColors = True
    Table1.SetColumnColors(Array As Int(Colors.White, 0xFF98F5FF, 0xFFFFC0FF, 0xFFC0FFC0, 0xFFFFFFC0))
    Table1.SetTextColors(Array As Int(Colors.Black, 0xFF800000, 0xFF0000FF, 0xFF004000, 0xFF400040))
    Table1.SetHeaderColors(Array As Int(Colors.Black, 0xFF800000, 0xFF0000FF, 0xFF004000, 0xFF400040))
    Table1.SetHeaderTextColors(Array As Int(Colors.White, 0xFF98F5FF, 0xFFFFC0FF, 0xFFC0FFC0, 0xFFFFFFC0))

    Query = "SELECT * FROM " & DBTableName1
    Log(Query)
'    Query = "SELECT * FROM " & DBTableName & " ORDER BY LastName ASC"
   
    Table1.LoadSQLiteDB(SQL1, Query, True)

But then I'm getting below Error:-

** Activity (status_reports_charts) Create, isFirst = true **
** Activity (status_reports_charts) Resume **
Error occurred on line: 299 (table)
java.lang.NullPointerException
at whse.deliverystatus.table._innerclearall(table.java:1085)
at whse.deliverystatus.table._clearall(table.java:129)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:305)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:77)
at android.view.View.performClick(View.java:4392)
at android.view.View$PerformClick.run(View.java:18156)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5406)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Resume **


Error occurred on line: 299 (table)
B4X:
Private Sub innerClearAll(vNumberOfColumns As Int)
    SelectedRows.Initialize
This is the Line 299
 
Upvote 0

Devan

Member
Licensed User
Longtime User
Oops Sorry to post same post twice.
 
Upvote 0

Devan

Member
Licensed User
Longtime User
Hi Mr.Klaus,
Sorry for the delay response. I manage to find out the reason for the Error.
1. I didn't Initialize the Table.
2. The below Array have 5 parameter Example as this : ((Array As Int(Colors.White, 0xFF98F5FF, 0xFFFFC0FF, 0xFFC0FFC0, 0xFFFFFFC0))
B4X:
Table1.SetColumnColors(Array As Int(Colors.White, 0xFF98F5FF, 0xFFFFC0FF, 0xFFC0FFC0, 0xFFFFFFC0))
    Table1.SetTextColors(Array As Int(Colors.Black, 0xFF800000, 0xFF0000FF, 0xFF004000, 0xFF400040))
    Table1.SetHeaderColors(Array As Int(Colors.Black, 0xFF800000, 0xFF0000FF, 0xFF004000, 0xFF400040))
    Table1.SetHeaderTextColors(Array As Int(Colors.Red,0xFF98F5FF, 0xFFFFC0FF, 0xFFC0FFC0, 0xFFFFFFC0))

But than in my Table there is 13 column. So I guess this particular 4 lines gives the error.

Can We set the color in word (Example: Colors.Black) , instead of using this format (Example: 0xFF800000)
Thank you
 
Upvote 0

Devan

Member
Licensed User
Longtime User
Just want to share my 2 cents. Hopefully it help some 1.
The below Sub in Table Class Module is to set the total row count on the TableView display.
By changing the code I manage to change the color from Gray to Black. Size also has been increased.
This will be helpful to user.
B4X:
Public Sub setStatusLine(s As String)
    If (lblStatusLine.IsInitialized) Then lblStatusLine.Text = s
    lblStatusLine.TextColor = Colors.Black 
    lblStatusLine.TextSize = 30
End Sub
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Can We set the color in word (Example: Colors.Black) , instead of using this format (Example: 0xFF800000)
Sure you can. The color parameter is an Int.
The below Sub in Table Class Module is to set the total row count on the TableView display.
And where is the routine ?
 
Upvote 0
Top