Android Question B4XTable MaximumRowsPerPage and how do I center a checkbox

Robert Valentino

Well-Known Member
Licensed User
Longtime User
1st - can I set MaximumRowsPerPage to -1 or something that tells B4XTable to use as many rows as it can? and if I need to know how many there are I will query it?
Just seems like something I could care less about. Just fit as many as you can????

I have a checkbox in each row (NO Text, just checkbox) how do I center just the CheckBox "[]" the square?


1583446722537.png



Been a lot of head banging for me (certain things are backwards then normal - example being SetColorAndBorder is so different then colordrawable.initialize2) but things are coming together
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
1st - can I set MaximumRowsPerPage to -1 or something that tells B4XTable to use as many rows as it can? and if I need to know how many there are I will query it?
Just seems like something I could care less about. Just fit as many as you can????
The default value is 0 which means that there is no limit.
However there is a good reason why you do want to keep it when adding custom views. Together with BuildLayoutsCache it allows you to add the views once and not worry that more items will be visible later. You can set the limit to 50 and forget about it.

certain things are backwards then normal - example being SetColorAndBorder is so different then colordrawable.initialize2
Calling B4XView.SetColorAndBorder is actually simpler than creating a new drawable. You just need to get used to it.

Example: make sure to use the latest version of B4XTable:
B4X:
Sub Globals
    Private B4XTable1 As B4XTable
    Private CheckedColumn As B4XTableColumn
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    CheckedColumn = B4XTable1.AddColumn("Checked", B4XTable1.COLUMN_TYPE_VOID)
    CheckedColumn.Width = 80dip
    B4XTable1.AddColumn("Entry", B4XTable1.COLUMN_TYPE_NUMBERS)
    B4XTable1.MaximumRowsPerPage = 50
    B4XTable1.BuildLayoutsCache(B4XTable1.MaximumRowsPerPage)
    B4XTable1.RowHeight = 50dip
    Dim data As List
    data.Initialize
    For i = 1 To 100
        data.Add(Array(i))
    Next
    Wait For (B4XTable1.SetData(data)) Complete (Unused As Boolean)
    For i = 1 To CheckedColumn.CellsLayouts.Size - 1
        Dim p As B4XView = CheckedColumn.CellsLayouts.Get(i)
        Dim chk As CheckBox
        chk.Initialize("chk")
        p.AddView(chk, p.Width / 2 - 20dip, B4XTable1.RowHeight / 2 - 20dip, 40dip, 40dip)
    Next
End Sub

B4A_R7GFEoW3Wj.png
 
Upvote 0
Top