Android Question B4XTable selections: crash

toby

Well-Known Member
Licensed User
Longtime User
I'm getting errors while trying to implement table row selection. Could someone let me know what's wrong, please?

Steps to reproduce:
1. set one or more column to be hidden, such as
B4X:
    B4XTable1.VisibleColumns.RemoveAt(B4XTable1.VisibleColumns.IndexOf(NumberColumn))

2. Implement table selections as instructed here

You should get error logs like the following
Logger connected to: asus ASUS_X017DA
--------- beginning of main
Copying updated assets files (11)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Error occurred on line: 71 (B4XTableSelections)
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
at java.util.ArrayList.get(ArrayList.java:411)
at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
at b4a.example.b4xtableselections._refresh(b4xtableselections.java:313)
at b4a.example.main._b4xtable1_dataupdated(main.java:765)
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 anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1083)
at anywheresoftware.b4a.keywords.Common.CallSubNew(Common.java:1030)
at b4a.example.b4xtable$ResumableSub_ImplUpdateDataFromQuery.resume(b4xtable.java:3166)
at b4a.example.b4xtable._implupdatedatafromquery(b4xtable.java:2667)
at b4a.example.b4xtable._updatedata(b4xtable.java:2240)
at b4a.example.b4xtable._refresh2(b4xtable.java:990)
at b4a.example.b4xtable._refreshnow(b4xtable.java:3566)
at b4a.example.b4xtable$ResumableSub_SetData.resume(b4xtable.java:507)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
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 anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:250)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:370)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:159)
at android.app.ActivityThread.main(ActivityThread.java:6146)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
 

Attachments

  • B4XTable Selections.zip
    62.2 KB · Views: 177

toby

Well-Known Member
Licensed User
Longtime User
My workaround is to modify B4XTableSelections.Refresh() code
ignore hidden columns during refresh:
        Dim j As Int =mTable.VisibleColumns.IndexOf(col)
            If j>=0 Then
            Dim p As B4XView = col.CellsLayouts.Get(i + 1)
            Dim lbl As B4XView = p.GetView(col.LabelIndex)
            If RowSelected And (LineMode Or SelectedCells.IndexOf(col.Id) > -1) Then
                p.Color = SelectionColor
                lbl.TextColor = SelectedTextColor
            Else
                p.Color = clr
                lbl.TextColor = mTable.TextColor
            End If
            End If
 
Upvote 0
Top