Android Question SOLVED: AddAllAt and InsertAt Crashes?

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I am sure I must be just not seeing my mistake. But when I try to AddAllAt from one list to another or manually InsertAt into a list my routine crashes.

I've cut and pasted a example below.

B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Sub Class_Globals
	Private Root As B4XView
	Private xui As XUI
	
	Private List1 As List
	Private List2 As List
	
End Sub

Public Sub Initialize

'Please note this is just an example of what I am tying to do.

			List1.Initialize2(Array As Long(1, 2, 5, 6))         '  Init array as 1, 2, 5, 6
			List2.Initialize2(Array As Long(3, 4))                '  init array as 3, 4
			
#if _DoAddAll_
			List1.AddAllAt(2, List2)                                   '   this line will crash
#else
			For i = 0 To List2.Size-1
				List1.InsertAt(2+i, List2.Get(i))               '   this line will crash
			Next
#end if
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
	Root = Root1
	Root.LoadLayout("MainPage")
End Sub

'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.

Sub Button1_Click
	xui.MsgboxAsync("Hello world!", "B4X")
End Sub
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Found this post that explains never to use Initialize2 as it makes fixed lists

 
Upvote 0

Similar Threads

Top