Hello,
Thanks for your response in December of last year. I am finally getting to the point in my project where I need to return a list from Java library.
To make sure I understand your response I developed a small test library and small test B4A program.
The relevant code from the Java library:
public class CRTlr {
public String[] getStrings() {
String str;
String sRes[] = new String[5];
for (int i=0; i<5; i++) {
str = "This is String #" + i;
sRes[i] = str;
}
return(sRes);
}
public anywheresoftware.b4a.objects.collections.List getList() {
String str;
List<Object> myList = new ArrayList<Object>();
for (int i=0; i<5; i++) {
str = "This is List Item #" + i;
myList.add(str);
}
anywheresoftware.b4a.objects.collections.List l1 = new anywheresoftware.b4a.objects.collections.List();
l1.setObject(myList);
return(l1);
}
}
And the relevant code from B4A:
Sub bnStr_Click
Dim str() As String
str = CRTlr.Strings
lbOut.Text = ""
For i=0 To str.Length - 1
lbOut.Text = lbOut.Text & str(i) & CRLF
Next
End Sub
Sub bnLst_Click
Dim mlst As List
mlst = CRTlr.List
lbOut.Text = ""
For i=0 To mlst.Size - 1
lbOut.Text = lbOut.Text & mlst.Get(i) & CRLF
Next
End Sub
I've also attached a zip file that contains the Eclipse workspace project (I hope this can be imported into your eclipse workspace, but I am sure the Build paths will need to be modified), the compiled library.jar and.XML files, and the B4A project export.
I hope this might be a useful starting point for someone.
Note: I just realized the B4A code assumes landscape orientation but I did not explicitly set the orientation to landscape. If the phone is held in portrait mode some of the buttons may not be visible.
Barry.