B4J Question class in list

madru

Active Member
Licensed User
Longtime User
Good morning,

I am redoing a few my old applications to get rid of legacy stuff.....

in one of the apps I use a class stored in an array like this

B4X:
dim tsr() as mpegTsReader
tsr(packetCount).Initialize(mpegPacket, blockRead,errorFree)

I like to move that over to a List or Map to look it up easier, but I have no idea how to do it :(

B4X:
dim listtest as list
listtest.Initialize
listtest.add(tsr.Initialize(mpegPacket, blockRead,errorFree))

I thought that will work but unfortunately not

any ideas?

THX
 
Last edited:

Misterbates

Active Member
Licensed User
You're adding the value returned from the initialize sub. Normally, you should initialize first then add the class to the list
 
Upvote 0

EnriqueGonzalez

Expert
Licensed User
Longtime User
OK, thought it is doable in one go

I am not so sure, but in your initialize method you can do this.

B4X:
public sub initialize(args as string) as object

return me
end sub

now you can add it directly to your list.

also. you can add it even when it is not initialied.
 
Upvote 0
Top