Hello,
While creating dymanic items in ultimateListview I am getting error as below :
The below is my code:
Please advice
While creating dymanic items in ultimateListview I am getting error as below :
B4X:
Error occurred on line: 61 (Main)
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=10; index=12
at java.util.Arrays$ArrayList.get(Arrays.java:3769)
at anywheresoftware.b4a.objects.collections.List.Get(List.java:117)
at b4a.example.main._ulv_contectfill(main.java:438)
The below is my code:
B4X:
#Region Project Attributes
#ApplicationLabel: B4A Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim mylist As List
Private Pnl As Panel
Private ULV As UltimateListView
Dim mylist As List
Dim itemheight As Int=60dip
Dim Somearray(10) As String
Dim lbl As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
mylist.Initialize2(Somearray)
'Add the ULV Add view
ULV.AddLayout("MyList","ULV_Layoutcallback","ULV_ContectFill",itemheight,True)
'For loop to dynamically create the item
For i=0 To mylist.Size
ULV.BulkAddItems(mylist.Size,"MyList",0)
Next
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ULV_Layoutcallback(LayoutName As String, LayoutPanel As Panel)
lbl.Initialize("")
lbl.TextColor=Colors.Black
LayoutPanel.AddView(lbl,20,0, LayoutPanel.Width,LayoutPanel.Height)
End Sub
Sub ULV_ContectFill(ItemID As Long, LayoutName As String, LayoutPanel As Panel, Position As Int)
lbl.Text=mylist.Get(Position)
End Sub
Please advice