Hi, I am using B4XListTemplate to pop up week day list. I want to add index to the list items so i have applied option.set property. It is working fine for B4i however throws error for B4A. Code and Error log as below.
Error log...
Logger connected to: OnePlus IN2011
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 36 (B4XMainPage)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
at B4X.test.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1070)
at B4X.test.b4xpagesmanager._showpage(b4xpagesmanager.java:427)
at B4X.test.b4xpagesmanager._addpage(b4xpagesmanager.java:247)
at B4X.test.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:261)
at B4X.test.b4xpagesmanager._initialize(b4xpagesmanager.java:167)
at B4X.test.main._activity_create(main.java:419)
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:157)
at B4X.test.main.afterFirstLayout(main.java:105)
at B4X.test.main.access$000(main.java:17)
at B4X.test.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:240)
at android.os.Looper.loop(Looper.java:351)
at android.app.ActivityThread.main(ActivityThread.java:8423)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
... 25 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
... 26 more
Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
at java.util.Objects.checkIndex(Objects.java:359)
at java.util.ArrayList.set(ArrayList.java:477)
at anywheresoftware.b4a.objects.collections.List.Set(List.java:123)
at B4X.test.b4xmainpage._b4xpage_created(b4xmainpage.java:83)
... 28 more
** Activity (main) Resume **
ListTemplate Code:
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private Dialog As B4XDialog
Private Button As Button
Dim listtemplate As B4XListTemplate
End Sub
Sub Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Public Sub Initialize
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("Home_Page")
Dialog.Initialize(Root)
listtemplate.Initialize
listtemplate.AllowMultiSelection = True
listtemplate.MultiSelectionMinimum = 1
listtemplate.Options.Set(0, "Sunday")
listtemplate.Options.Set(1, "Monday")
listtemplate.Options.Set(2, "Tueday")
listtemplate.Options.Set(3, "Wednesday")
listtemplate.Options.Set(4, "Thursay")
listtemplate.Options.Set(5, "Friday")
listtemplate.Options.Set(6, "Saturday")
End Sub
Private Sub B4XPage_Appear()
End Sub
Private Sub B4XPage_Resize(Width As Float, Height As Float)
End Sub
Private Sub B4XPage_Foreground
End Sub
Private Sub Button_Click
Dim sf As Object = Dialog.ShowTemplate(listtemplate, "Ok", "", "Cancel")
Wait For (sf) Complete (Result As Int)
If Result = xui.DialogResponse_Positive Then
Log(listtemplate.SelectedItems)
End If
End Sub
Error log...
Logger connected to: OnePlus IN2011
** Activity (main) Resume **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 36 (B4XMainPage)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1087)
at B4X.test.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1070)
at B4X.test.b4xpagesmanager._showpage(b4xpagesmanager.java:427)
at B4X.test.b4xpagesmanager._addpage(b4xpagesmanager.java:247)
at B4X.test.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:261)
at B4X.test.b4xpagesmanager._initialize(b4xpagesmanager.java:167)
at B4X.test.main._activity_create(main.java:419)
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:157)
at B4X.test.main.afterFirstLayout(main.java:105)
at B4X.test.main.access$000(main.java:17)
at B4X.test.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:240)
at android.os.Looper.loop(Looper.java:351)
at android.app.ActivityThread.main(ActivityThread.java:8423)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:336)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
... 25 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
... 26 more
Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
at java.util.Objects.checkIndex(Objects.java:359)
at java.util.ArrayList.set(ArrayList.java:477)
at anywheresoftware.b4a.objects.collections.List.Set(List.java:123)
at B4X.test.b4xmainpage._b4xpage_created(b4xmainpage.java:83)
... 28 more
** Activity (main) Resume **