Android Question Build ArrayList in B4A for using in Lib

Ferdari

Active Member
Licensed User
Longtime User
Hi everyone, i want to write this Java ArrayList on B4A:
Java:
    protected Pack(Parcel in) {
        identifier = in.readString();
        name = in.readString();
        publisher = in.readString();
        trayImageFile = in.readString();
        publisherEmail = in.readString();
        publisherWebsite = in.readString();
        privacyPolicyWebsite = in.readString();
        licenseAgreementWebsite = in.readString();
        iosAppStoreLink = in.readString();
        stickers = in.createTypedArrayList(Sticker.CREATOR); //this is also and arraylist
        totalSize = in.readLong();
        androidPlayStoreLink = in.readString();
        isWhitelisted = in.readByte() != 0;
    }
What is the best way to write this on B4A?

content.Initialize("", ArrayList)

Im creating an array:
B4X:
'Array As String("identifier","name","publisher,"trayImageFile","publisherEmail","publisherWebsite","privacyPolicyWebsite","licenseAgreementWebsite","iosAppStoreLink","stickers()","totalSize","androidPlayStoreLink","isWhitelisted")
Array As String("12","App","tray","","","","","","","",stickers,"","")
 
Last edited:

Ferdari

Active Member
Licensed User
Longtime User
Thanks, it works, but not the lib im developing ?
 
Upvote 0

asales

Expert
Licensed User
Longtime User
Thanks, it works, but not the lib im developing ?
Maybe a Map instead an array:
B4X:
    Private Pack As Map
    Pack.Initialize
    Pack.Put("identifier", "<identifier1>")
    Pack.Put("name", "<name>1")

    Dim list1 As List = Array As String("stickers1", "stickers2", "stickers3")
    Pack.Put("stickers", list1)

    Pack.Put("totalSize", 1000)
    
    Log(Pack.Get("identifier"))   '<identifier1>
    Log(Pack.Get("name"))    '<name>1
    Log(Pack.Get("stickers"))   '[stickers1, stickers2, stickers3]
    Log(Pack.Get("totalSize"))   '1000
 
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
I tried, but the app can´t compile with MAP: $MyMap cant be converted to ArrayList, i need more research
 
Upvote 0

asales

Expert
Licensed User
Longtime User
I tried, but the app can´t compile with MAP: $MyMap cant be converted to ArrayList, i need more research
Maybe this;
?
@Erel says: "B4A List wraps the Java ArrayList. They are the same thing."
 
Upvote 0

Ferdari

Active Member
Licensed User
Longtime User
Im using Lists intead of Map, it works, but need to fix the lib, because it are not adding the StickerPack. ill report back.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…