I'm getting a strange error doing something fairly basic. It has worked fine in the past though its been some time since I used this feature.
Basically a customlistview has some checkboxes. For each one checked, a Type variable from the 'All' list gets copied to the 'Selected' list. It then calls another activity that uses the 'Selected' list to do stuff.
If the number of items added to 'Selected' list=1, all is fine. If >1, then I get an error on line 'If Main.glstSelectedLists.Size = 1 Then'
Error:
StartActivity(UserList)
** Activity (main) Pause, UserClosed = false **
** Activity (userlist) Create, isFirst = true **
UserList_Activity_Create
Main.glstSelectedLists.Size=2
Error occurred on line: 68 (UserList)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at com.QuikList.userlist$ResumableSub_Activity_Create.resume(userlist.java:471)
at com.QuikList.userlist._activity_create(userlist.java:408)
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:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
Line numbers 67 & 68 above are just to demonstrate where the fail is happening.
So line 67 is fine using Main.glstSelectedLists.Size which = 2
but line 68 gives an error testing if Main.glstSelectedLists.Size > 1 BUT ONLY if Main.glstSelectedLists.Size is actually > 1
What gives?
B4A 11.00. Java 11
Basically a customlistview has some checkboxes. For each one checked, a Type variable from the 'All' list gets copied to the 'Selected' list. It then calls another activity that uses the 'Selected' list to do stuff.
If the number of items added to 'Selected' list=1, all is fine. If >1, then I get an error on line 'If Main.glstSelectedLists.Size = 1 Then'
Error:
StartActivity(UserList)
** Activity (main) Pause, UserClosed = false **
** Activity (userlist) Create, isFirst = true **
UserList_Activity_Create
Main.glstSelectedLists.Size=2
Error occurred on line: 68 (UserList)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at com.QuikList.userlist$ResumableSub_Activity_Create.resume(userlist.java:471)
at com.QuikList.userlist._activity_create(userlist.java:408)
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:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
B4X:
--- Main ---------------------------
Sub Process_Globals
Dim glstSelectedLists As List
Dim glstAllLists As List
Type MainListRow(ListNo As Int, ListName As String, ListAbbr As String, DelSrcWhenPicked As Boolean, MasterList As String, R As Int, G As Int, B As Int, HighlightCnt As Boolean, MasterKbd As Boolean, MasterImm As Boolean)
Sub mnuLoadMains_Click
Dim intCnt1 As Int
Dim pnl As Panel
Dim lbl As Label
Dim chk As CheckBox
Dim mlr As MainListRow
glstSelectedLists.Clear
For intCnt1 = 0 To clvMain.GetSize-1
pnl = clvMain.GetPanel(intCnt1)
chk = pnl.GetView(0)
If chk.Checked Then
lbl = pnl.GetView(1)
mlr = glstAllLists.Get(lbl.Tag)
glstSelectedLists.Add(mlr)
End If
Next
If glstSelectedLists.Size > 0 Then
Log("StartActivity(UserList)")
StartActivity(UserList)
End If
End Sub
-- UserList ---------------------
Sub Activity_Create(FirstTime As Boolean)
Dim mlrList As MainListRow
Log("UserList_Activity_Create")
67 Log("Main.glstSelectedLists.Size=" & Main.glstSelectedLists.Size)
68 If Main.glstSelectedLists.Size = 1 Then
Line numbers 67 & 68 above are just to demonstrate where the fail is happening.
So line 67 is fine using Main.glstSelectedLists.Size which = 2
but line 68 gives an error testing if Main.glstSelectedLists.Size > 1 BUT ONLY if Main.glstSelectedLists.Size is actually > 1
What gives?
B4A 11.00. Java 11
Last edited: