Android Question how to customize the header of the b4xtable

Mahares

Expert
Licensed User
Longtime User
specifically the arrows to turn the page and textsize
To change the arrows colors:
B4X:
Sleep(0)  '
    B4XTable1.lblFromTo.TextColor= Colors.Cyan      'exple: 1 to 18
    B4XTable1.lblNumber.TextColor=Colors.Red  '1 the page numbers in red. you can also use XUI colors
    B4XTable1.ArrowsEnabledColor=Colors.green  'enable arrow color
    B4XTable1.ArrowsDisabledColor=Colors.Gray   'disabled arrow color

To change the style of the arrows, I use something like this:
B4X:
Dim cs As CSBuilder
    cs.Initialize.Typeface(Typeface.FONTAWESOME).Append(Chr(0xF061)).popall
    B4XTable1.lblNext.Text=cs  'to change the next page arrow from one type of arrow to another
    cs.Initialize.Typeface(Typeface.FONTAWESOME).Append(Chr(0xF060)).popall
    B4XTable1.lblBack.Text=cs

To change the data textsize. Here for all columns text, but maybe more suitable for a given or a number of columns.:
B4X:
For Each c As B4XTableColumn In B4XTable1.Columns  
    For i = 1 To c.CellsLayouts.Size - 1
        Dim pnl As B4XView = c.CellsLayouts.Get(i)
        Dim lbl As Label = pnl.GetView(0)
        lbl.Typeface = Typeface.DEFAULT_BOLD
        lbl.TextSize = 20
        lbl.TextColor =XUI.Color_Blue
    Next
Next
 
Last edited:
Upvote 0

Emerito

Active Member
Licensed User
Longtime User
Muchas gracias. Pero para las labels : lblFromTo, lblNumber, lblNext, etc. me pide que las inicialize. No se hacerlo. Disculpa mi ignorancia . Saludos.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Muchas gracias. Pero para las labels : lblFromTo, lblNumber, lblNext, etc. me pide que l
Please answer in English, I have no idea what you said. Either ut a 'Like' or say it is ok in English, unless you want to put something negative. No spanish.
 
Last edited:
Upvote 0

Emerito

Active Member
Licensed User
Longtime User
excuse me.
Thank you very much, but for the labels (lblFromTo, lblNumber, etc. ) it asks me to initialize and i do not know how to do it.
I´m sorry my english.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
(lblFromTo, lblNumber, etc. ) it asks me to initialize
No, it should not ask you to inititialze anything. Post your code and where you place it in the overall code. If you table is B4XTable1, it has to be something like this example: B4XTable1.lblFromTo.TextColor= Colors.Cyan
I use B4XTable library 1.21.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I am using version 1.11 Where can I download 1.21?
Read the bottom of post 1 by Erel in the following link. It tells you it is an internal library. If you are using a B4Xtable class, you need to remove it and use the
library:

Do not use a class module. Use the library.
 
Upvote 0

Emerito

Active Member
Licensed User
Longtime User
Yes, I have. I've downloaded the library again, but it's still version 1.1
I don't know what happens. Tomorrow I will continue.
Thank you.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Yes, I have. I've downloaded the library again, but it's still version 1.1
It is possible that you have an old library 1.1 in your ADDITIONAL library folder . Make sure you delete that one. It used to be an external library until Monsieur Erel made it internal. The lib is internal so all you need to do is remove the class module only if you are using a class module and check the lib in the lib pane in IDE.
 
Upvote 0

Emerito

Active Member
Licensed User
Longtime User
I've already managed to upgrade to version 1.21, but I keep getting the same error on line 84 and 85:
B4X:
Sub Activity_Create(FirstTime As Boolean)

    Label1.Initialize("")
    Label1.Top=0dip
    Label1.Left=0dip
    EditText1.Initialize("")
    EditText1.Top=10dip
    EditText1.Left=Label1.Width
    EditText1.Height=30dip
    
    IME.Initialize("ime")
    IME.AddHeightChangedEvent
    
    
    Activity.LoadLayout("Tabla")
    Activity.Title=Main.ProgName & " " & Main.ProgVersion
    
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Pulgadas", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Milimetros", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("DENOMINACION", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 380dip
    StateColumn.Sortable = True
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Grains", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Gramos", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("CB", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("V0", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("V50", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("V100", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("V150", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("V200", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("V250", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("V300", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Visor", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Alt50", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Alt100", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Alt150", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Alt200", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Alt250", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Alt300", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Energ0", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Energ50", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Energ100", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Energ150", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Energ200", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Energ250", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Energ300", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("DS", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip
    Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Id", B4XTable1.COLUMN_TYPE_NUMBERS)
    StateColumn.Width = 60dip

    NumberColumn = B4XTable1.AddColumn("Interesting Number", B4XTable1.COLUMN_TYPE_NUMBERS)
    NumberColumn.Width=1dip
    
    B4XTable1.RowHeight=50dip


    B4XTable1.lblFromTo.TextColor= Colors.Cyan      'exple: 1 to 18
    B4XTable1.lblNumber.TextColor=Colors.Red  '1 the page numbers in red. you can also use XUI colors
    B4XTable1.ArrowsEnabledColor=Colors.blue  'enable arrow color
    B4XTable1.ArrowsDisabledColor=Colors.Gray   'disabled arrow color


'
java.lang.RuntimeException: Object should first be initialized (B4XView).
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
You need to add Sleep(0) before accessing the internal views.
1. It is strange, because before I helped the OP with the code for the internal views, I tested in my project first , I have no Sleep(0) before assigning the data and data type to the table and it worked for me unless you count the one immediately after loading the layout. What is it with this elusive Sleep(0). Sometimes you need it, sometimes you don't and sometimes its placement in the code is mysterious.
2. Why is the OP doing this with every assignment of the table data and type:
B4X:
Dim StateColumn As B4XTableColumn = B4XTable1.AddColumn("Pulgadas", B4XTable1.COLUMN_TYPE_TEXT)
    StateColumn.Width = 60dip
You can just simply use this form to simplify and streamline the code or use an array to identify the columns and data type:
B4X:
B4XTable1.AddColumn("Pulgadas", B4XTable1.COLUMN_TYPE_TEXT).Width =60dip
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1.
unless you count the one immediately after loading the layout
I do. B4XTable loads a layout internally in DesignerCreateView. This requires calling Sleep(0) in B4XTable code as it is not possible to load a layout while the parent layout is loaded.
This means that you should also have Sleep(0) in your code if you intend to access the internal views.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…