B4J Question Tableview change row color/font properties (make it bold)

Magma

Expert
Licensed User
Longtime User
Hi there...

actually i wanna check when i am reading by row a table a column for value and then make the "whole" row of tableview bold+changing color... is it possible and how ?

Somewhere read about assigning labels as columns but i can't figure it...

my working code is this:
B4X:
cursor1 = sql1.ExecQuery("SELECT * from eworks WHERE ID >" & lastid & " ORDER BY ID ASC;")
    Do While cursor1.NextRow
        Dim values(cursor1.ColumnCount) As String
        bbold=False
        For col = 0 To cursor1.ColumnCount - 1
            Select Case col
            Case 0
                values(col) = NumberFormat2(cursor1.GetString2(col),10,0,0,False)
            Case 4
                If values(col)="" Then bbold=True
            Case Else
                values(col) = cursor1.GetString2(col)
            End Select
        Next
        lastid = cursor1.GetString2(0)
        'TableView2.items ---- make something/magic to make it bold :-)
        TableView2.Items.Add(values)
'or afer adding it ? i need that too.. to turn it normal... if need for other reasons..
    Loop
    cursor1.Close
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
lbl.Typeface = Typeface.DEFAULT_BOLD
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
Hmm... works :)

but i have a question... is it faster to do it with set (like your example) or make a label with bold checked and changed color and just clone / which from two is faster - i have a question because i have 3 loops with thousand of records and i wanna check and change colors...
 
Upvote 0

Magma

Expert
Licensed User
Longtime User
I have a second question too :)... i am a gonna break my head...

I am getting this error:
main._changestimer1_tick (java line: 138)
java.lang.NullPointerException
at b4j.example.main._changestimer1_tick(main.java:138)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:90)
at anywheresoftware.b4a.objects.Timer$TickTack$1.run(Timer.java:118)
at com.sun.javafx.application.PlatformImpl.lambda$null$173(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$174(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$148(WinApplication.java:191)
at java.lang.Thread.run(Thread.java:748)

From this code:
B4X:
Sub changestimer1_tick
    changestimer.Enabled=False

        For k=0 To TableView2.Items.Size-1
            Dim row() As Object = TableView2.Items.Get(k)
            Dim lbl(TableView2.ColumnsCount) As Label
          
            For t=0 To TableView2.ColumnsCount-1
                lbl(t).Initialize("label")
                lbl(t) = row(t)
            Next


            If cint(lbl(19).text)=0 Or cint(lbl(15).text)=0 Then
                id=cint(lbl(0).Text)

                cursor2 = sql1.ExecQuery("SELECT * from eworks WHERE id=" & id & ";")
              
                Do While cursor2.NextRow

                    If cursor2.GetString2(15)="0" Then lbl(15).Text="0" Else lbl(15).text=cursor2.GetString2(15)

                    If cursor2.GetString2(19)="0" Then lbl(19).Text="0" Else lbl(19).text=cursor2.GetString2(19)

                    If isNull(cursor2.GetString2(8))=True Then lbl(8).Text="" Else lbl(8).text=cursor2.GetString2(8)

                Loop
              
                cursor2.Close
            End If

            For t=0 To TableView2.ColumnsCount-1
                row(t)=lbl(t)
            Next

        TableView2.Items.Set(k,row)
      

        Next

    changestimer.Enabled=True
End Sub

What exactly do this code - is checking about 136 records (this will be ~2000) - if something changed will change it after some seconds and at screen...

My problem is when tableview2.item.size is smaller than or = 100 working ok - if more gives the error!

any idea ?

ps: by the way seems little heavy changing label color and font bold... :-(
 
Last edited:
Upvote 0

Magma

Expert
Licensed User
Longtime User
as i can understand:
B4X:
            Dim row() As Object = TableView2.Items.Get(k)

when "k" goes at 101..
but i have more than 100 rows.. .about 136..

...Now i am checking bigger tables... and i am seeing that putting labels in it and change colors and make them bold is to heavy... i am gonna change programmaticaly idea.. may be i ll use 2-3 tableviews.
 
Upvote 0
Top