I am attempting to do a 2 dimensional label array (think of a grid of labels). But it doesnt work.
Here is my feeble attempt:
But it gets an error:
main.java:402: error: incompatible types: LabelWrapper[][] cannot be converted to LabelWrapper[]
if (true) return (anywheresoftware.b4j.objects.LabelWrapper[])(_lbls);
Thoughts?
Here is my feeble attempt:
B4X:
'2 Dimensional Array
Sub CollectNodes2D(Tags() As String) As Label()
Dim TagsIndex As Int
Dim lblsList(Tags.length) As List
Dim MaxListSize As Int
For TagsIndex = 0 To Tags.Length-1
lblsList(TagsIndex).Initialize
For I = 0 To OutputWindow.RootPane.NumberOfNodes - 1
Dim n As Node = OutputWindow.RootPane.GetNode(I)
If n.Tag <> Null And n.Tag = Tags(TagsIndex) Then lblsList(TagsIndex).Add(n)
Next
If MaxListSize < lblsList(TagsIndex).Size Then MaxListSize = lblsList(TagsIndex).Size 'Grab our largest list so the array variable can hold it.
Next
Dim lbls(Tags.length, MaxListSize) As Label'Declare a large enough 2D array
For TagsIndex = 0 To Tags.Length - 1
For i = 0 To lbls.Length - 1
Dim lbl As Label = lblsList(TagsIndex).Get(i)
lbls(TagsIndex, i) = lbl
Next
Next
Return lbls
End Sub
But it gets an error:
main.java:402: error: incompatible types: LabelWrapper[][] cannot be converted to LabelWrapper[]
if (true) return (anywheresoftware.b4j.objects.LabelWrapper[])(_lbls);
Thoughts?