Java Question Accessing an ArrayList from a class

thedesolatesoul

Expert
Licensed User
Longtime User
A public class:
B4X:
public static class Entry extends DropboxReturn {
is defining an ArrayList of itself
B4X:
public ArrayList<Entry> contents;

so anything that will call this class contains an array of itself.

How do I access the members of the array from b4a?
Even though I know the variables in the contents array I cannot access them.

EDIT: One way is to write a function to grab them.:sign0161:
 
Last edited:

Nerdworld

Member
Licensed User
Longtime User
java.lang.RuntimeException: Field: length not found in: java.util.ArrayList

I just tried to loop through an ArrayList. :D
I'm going to investigate how to access it.

Edit, solved it this way:

B4X:
Dim Obj As JavaObject = ...
Obj.RunMethod("getStringArrayList", ...)
For i = 0 To Obj.RunMethod("size", Array As Object()) - 1
     Log(Obj.RunMethod("get", Array As Object(i)))
Next
 
Last edited:
Top