Mar 4, 2026 Replies: 2 B4X compiler automatically casts arrays to lists. You can use this code in the rare case where you want to convert a list to an array of objects: Code: Public Sub ListToArray(Items As List) As Object() #if B4A or B4J Return Items.As(JavaObject).RunMethod("toArray", Null) #Else Dim b(Items.Size) As Object For i = 0 To Items.Size - 1 b(i) = Items.Get(i) Next Return b #End If End Sub Last edited: Mar 5, 2026 Click to expand...
B4X compiler automatically casts arrays to lists. You can use this code in the rare case where you want to convert a list to an array of objects: Code: Public Sub ListToArray(Items As List) As Object() #if B4A or B4J Return Items.As(JavaObject).RunMethod("toArray", Null) #Else Dim b(Items.Size) As Object For i = 0 To Items.Size - 1 b(i) = Items.Get(i) Next Return b #End If End Sub
Daestrum Expert Licensed User Longtime User Mar 4, 2026 #2 I might be wrong, but B4I code path doesn't seem to return anything. (Think a line is missing in your example) Last edited: Mar 4, 2026
I might be wrong, but B4I code path doesn't seem to return anything. (Think a line is missing in your example)