A aligol Member Jan 18, 2023 #1 For i=1 To 80 Dim n As B4XView = xui.CreatePanel("mm") n.SetLayoutAnimated(0,0,0,100%x,40dip) n.LoadLayout("L_items_unit") Label1.Text="unite"& i clv_units.Add(n,"") Next Click to expand... Error occurred on line: 42 (Main) java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.objects.collections.List.getSize()' on a null object reference at b4a.example3.customlistview._add(customlistview.java:71) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354) 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 b4a.example.main.afterFirstLayout(main.java:105) at b4a.example.main.access$000(main.java:17) at b4a.example.main$WaitForLayout.run(main.java:83) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6190) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) Click to expand... I wrote a code a while ago and that worked perfectly , but now it gives me this error. I'm new and don't know where is this problem occur and how solve that. I'll be appreciate if some one help me.
For i=1 To 80 Dim n As B4XView = xui.CreatePanel("mm") n.SetLayoutAnimated(0,0,0,100%x,40dip) n.LoadLayout("L_items_unit") Label1.Text="unite"& i clv_units.Add(n,"") Next Click to expand... Error occurred on line: 42 (Main) java.lang.NullPointerException: Attempt to invoke virtual method 'int anywheresoftware.b4a.objects.collections.List.getSize()' on a null object reference at b4a.example3.customlistview._add(customlistview.java:71) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777) at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354) 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 b4a.example.main.afterFirstLayout(main.java:105) at b4a.example.main.access$000(main.java:17) at b4a.example.main$WaitForLayout.run(main.java:83) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6190) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:892) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782) Click to expand... I wrote a code a while ago and that worked perfectly , but now it gives me this error. I'm new and don't know where is this problem occur and how solve that. I'll be appreciate if some one help me.
Alexander Stolte Expert Licensed User Longtime User Jan 18, 2023 #2 in which line does the error occur? best to share the project. Upvote 0
M Mahares Expert Licensed User Longtime User Jan 18, 2023 #3 Alexander Stolte said: best to share the project. Click to expand... aligol said: I'll be appreciate if some one help me Click to expand... Theoretically, your code looks perfect although it looks better if you use code tags. See below: Code: Copy For i=1 To 80 Dim n As B4XView = XUI.CreatePanel("mm") n.SetLayoutAnimated(0,0,0,100%x,40dip) n.LoadLayout("L_items_unit") Label1.Text="unite"& i clv_units.Add(n,"") Next The error is somewhere else, not in this code. As the powerhouse Alexander suggested.: Attach your project reproducing the error or post a lot more relevant code. Upvote 0
Alexander Stolte said: best to share the project. Click to expand... aligol said: I'll be appreciate if some one help me Click to expand... Theoretically, your code looks perfect although it looks better if you use code tags. See below: Code: Copy For i=1 To 80 Dim n As B4XView = XUI.CreatePanel("mm") n.SetLayoutAnimated(0,0,0,100%x,40dip) n.LoadLayout("L_items_unit") Label1.Text="unite"& i clv_units.Add(n,"") Next The error is somewhere else, not in this code. As the powerhouse Alexander suggested.: Attach your project reproducing the error or post a lot more relevant code.