Android Question Table with fixed first column

harinder

Active Member
Licensed User
Longtime User
My requirement is to display a table with fixed first column and both horizontal and vertical scrolling. B4X Table has column freeze function but does not support vertical scrolling(I think !!). FlexiTable supports H/V scrolling but no column freeze. Presently I am using FlexiTable, but want first column freeze. Thanks.
 

klaus

Expert
Licensed User
Longtime User
Is this, what you are looking for?

upload_2019-12-24_16-48-39.png
upload_2019-12-24_16-49-1.png


It's a work in progress with the Flexible Table.
Needs still some more tests.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
The Flexible Table has been updated in the first post.
Excellent. Works well. To see the horizontal scrolling in action and accentuate the fixed column, I added one more column to the table. I changed this line:
B4X:
Table1.LoadSQLiteDB(Starter.SQL1, "SELECT * FROM persons", True)
to this line in klaus's code example:
B4X:
Table1.LoadSQLiteDB(Starter.SQL1, "SELECT FirstName || ' Expert B4X Programmer' as NickName, FirstName , LastName, ID, Address,  City, Number FROM persons", True)
 
Upvote 0

harinder

Active Member
Licensed User
Longtime User
Hello Klaus..Thank you for your efforts :)
I tested the new Table class in my project. On initial use, the first column freeze worked perfectly, but on adding or removing rows, I got an out of bound exception of array equal to number of columns, pointing to line 681 of the new Table class.
B4X:
lbls(0).SetLayout(0, lbls(col).Top, mFirstColumnWidth, cRowHeight - cLineWidth)
On removing this line, firstcolumn freeze WORKS WELL with all 4 tables in my project now, even after adding/deleting rows..Thank You
 
Upvote 0

harinder

Active Member
Licensed User
Longtime User
Hello Klaus...I tested the class you sent..Now I am getting the following error on initial loading itself, pointing to line 689 of the class. I have 9 columns in my tables.

IMG_20191226_215329.jpg



On fremoving the line 689, which is as follows,all well again
B4X:
lbls(0).SetLayout(0, lbls(col).Top, mFirstColumnWidth, cRowHeight - cLineWidth)

Error log as follows:

Error occurred on line: 689 (Table)
java.lang.ArrayIndexOutOfBoundsException: length=9; index=9
at harry.logbook.table._setcolumnswidths(table.java:1614)
at harry.logbook.table._addrowautomaticwidth(table.java:662)
at harry.logbook.main._tableview(main.java:1065)
at harry.logbook.main._emptytableschk(main.java:567)
at harry.logbook.main._activity_create(main.java:503)
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 harry.logbook.main.afterFirstLayout(main.java:104)
at harry.logbook.main.access$000(main.java:17)
at harry.logbook.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:221)
at android.app.ActivityThread.main(ActivityThread.java:7520)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
** Activity (main) Resume **
 
Upvote 0

harinder

Active Member
Licensed User
Longtime User
Hi Klaus..As I mentioned, it is working fine after deleting row no 689 in Table Class.. there seems to be an issue with that..
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
As already mentioned, I cannot reproduce your error. It works OK in the demo program.
As already mentioned, can you please post your project, or better a small one showing the problem, so I can test and see what happens in your case!
 
Upvote 0
Top