Android Question [Solved][B4XTable] - Horizontal scroll

GabrielM

Member
Licensed User
Longtime User
a.)
In a B4A application, in a B4XTable, I am trying to have one frozen column (something like a Header) and just one selected column (there are 3 of them).

Say I choose to show "Col2" besides the frozen column, hiding other columns (except first one): and that is showing OK,
the only thing I am after is " how to "lock" or disable the horizontal scroll of it ?.
When it shows up, if you click and drag it the column will slide in that direction.

b.)
I can not figure out where my error is when I try to show "Col3" (that is the last column added initially) I get this log"
b4xtable_resizeandreorderclvitems (java line: 2248)
' java.lang.RuntimeException: Object should first be initialized (View).
' Did you forget to call Activity.LoadLayout?
' at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
' at anywheresoftware.b4a.objects.B4XViewWrapper.GetView(B4XViewWrapper.java:318)
' at b4a.example3.customlistview._getpanel(customlistview.java:440)
' ...

I have attached the B4A code I am using for testing ( actually a modified example from this forum).
 

Attachments

  • B4XTableExample_1.zip
    11 KB · Views: 70

Mahares

Expert
Licensed User
Longtime User
the only thing I am after is " how to "lock" or disable the horizontal scroll of it ?.
I can not figure out where my error is when I try to show "Col3
I moved the B4XTable1.NumberOfFrozenColumns = 1 line inside the Show sub, see the code below. Because it needs to be after you reassigned the columns. This should take care of both of your problems a and b:
B4X:
Sub showColAtOne(tbl As B4XTable, ColumnId As String)
    Dim column As B4XTableColumn = tbl.GetColumn(ColumnId)
    tbl.VisibleColumns.InsertAt(1, column)
    B4XTable1.NumberOfFrozenColumns = 1  '<----- needs to be here after reassigning the coloumns
    tbl.Refresh
End Sub
 
Upvote 0

GabrielM

Member
Licensed User
Longtime User
I moved the B4XTable1.NumberOfFrozenColumns = 1 line inside the Show sub, see the code below. Because it needs to be after you reassigned the columns. This should take care of both of your problems a and b:
B4X:
Sub showColAtOne(tbl As B4XTable, ColumnId As String)
    Dim column As B4XTableColumn = tbl.GetColumn(ColumnId)
    tbl.VisibleColumns.InsertAt(1, column)
    B4XTable1.NumberOfFrozenColumns = 1  '<----- needs to be here after reassigning the coloumns
    tbl.Refresh
End Sub

Indeed that cured my mistakes, fantastic :)

I really appreciate your help @Mahares , now I have to dig deeper so I understand it.
Anyways, it seems that there is this rule as you say, the NumberOfFrozenCollums should be always set after any change on VisibleColumns setting.

Thank you
 
Upvote 0
Top