Android Question B4XTable Page Number Color

Scantech

Well-Known Member
Licensed User
Longtime User
How do i change the B4xTable Page TextColor? I am using appcompat and its black and not what i want.
 

jimmyF

Active Member
Licensed User
Longtime User
Put this code in your B4XTable1_DataUpdated sub

B4X:
B4XTable1.lblNumber.TextColor = xui.Color_Blue

hth
-j
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Change it with the designer:
B4J_vYEYuTAHuR.png
 
Upvote 0

jimmyF

Active Member
Licensed User
Longtime User
Change it with the designer:
Yes, of course.

I was thinking that it is sometimes advantageous to know how to do it in code.
Indicating last page, end/beginning of file, or something like that.

-j
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
The reason why i ask is because in runtime it gives me error. Not initialized (lblNumber). I will try the designer
 
Upvote 0

jimmyF

Active Member
Licensed User
Longtime User
Apparently not.

Put the code I posted at the end of the Sub I mentioned.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
This line as posted by Jimmy in post#2 works:
B4X:
B4XTable1.lblNumber.TextColor = xui.Color_Blue
But, it does not necessarily have to be in this sub: B4XTable1_DataUpdated sub.
I put it in the Activity_Create and it worked:
 
Upvote 0

jimmyF

Active Member
Licensed User
Longtime User
I put it in the Activity_Create and it worked
I forgot to mention that I was using the B4XTable in a Class so all my table code is there.
 
Upvote 0

Scantech

Well-Known Member
Licensed User
Longtime User
I don't know how you guys got it to work.
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
No wakelock.
** Activity (diagreport) Create, isFirst = true **
Class not found: b4a.example.b4xtable, trying: scantech.cardiagnosticpro.b4xtable
Index time: 4 ms
Index time: 6 ms
Error occurred on line: 62 (DiagReport)
java.lang.RuntimeException: Object should first be initialized (B4XView).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
at anywheresoftware.b4a.objects.B4XViewWrapper.asLabelWrapper(B4XViewWrapper.java:191)
at anywheresoftware.b4a.objects.B4XViewWrapper.setTextColor(B4XViewWrapper.java:216)
at scantech.cardiagnosticpro.diagreport._activity_create(diagreport.java:417)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at scantech.cardiagnosticpro.diagreport.afterFirstLayout(diagreport.java:104)
at scantech.cardiagnosticpro.diagreport.access$000(diagreport.java:17)
at scantech.cardiagnosticpro.diagreport$WaitForLayout.run(diagreport.java:82)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
** Activity (diagreport) Resume **

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
    '-----------------------------------------------------------------------------------------------------
    'ORIENTATION TYPE
    '-----------------------------------------------------------------------------------------------------
    Select Case StateManager.AppOrientationLoad
        Case "Portrait":   Starter.Orientation.SetScreenOrientation(1)
        Case "Landscape":  Starter.Orientation.SetScreenOrientation(0)
    End Select
   
    lv = GetDeviceLayoutValues
   
    InitTableandSql
    InitLogView
    InitPrinter
    InitViewSettings
   
    B4XTable1.lblNumber.TextColor = Colors.White
   
End Sub

This error occurs with all projects
 
Last edited:
Upvote 0

jimmyF

Active Member
Licensed User
Longtime User
It worked for me in Activity_Create. I cannot explain to you why though.
Just curious. Is all your B4XTable code in your activity?
Because that would make sense, I think, that you can set it Activity_Create, after you have initialized your B4XTable in that sub.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Wow i did not see your comment. It only works in B4XTable1_DataUpdated sub. B4Xtable needs improvement. It should work anywhere you call it.
It is not possible due to the way nested layouts are loaded.
You need to add Sleep(0) after you load the layout. Another option which covers all cases is to add Wait For B4XTable1_DataUpdated after you set the data. At that point everything will be ready.
 
Upvote 0
Top