Android Question B4A - Add Items to List

LowHZ

New Member
Licensed User
Hi all,
I got a problem with lists in B4A.
I have to add items to a list,
The list must be populated with a custom class, the class variables get populated by an API CALL that answer with a XML
To parse the xml i'm using XmlSax and inside this event:

B4X:
Sub parser1_EndElement (Uri As String, Name As String, Text As StringBuilder)
select case Name
case "test"
     myclass.name = Text
end sub

The class that must be populated is placed in the Globals Variables declarations

So in the process I populate the class that will be added to the list using the Parser.
Everytime it make a new call the class must be reset so i put in the code

myClass.Initialize

The problem is, everytime i make a new API CALL it gets the new response with different values
but when i try to add the class to the list, it adds everytime the class but with the same values of the previous item so i get only clones of the first item in the list.

How can i solve it?
 

LowHZ

New Member
Licensed User
Already done
It won't works

B4X:
            Dim myArticoloA As Articolo
            myArticoloA.Initialize
            myArticoloA.CodArt = myArticolo.CodArt
            myArticoloA.IdArticolo = myArticolo.IdArticolo
            myArticoloA.IdIVA = myArticolo.IdIVA
            myArticoloA.IdMagaz = myArticolo.IdMagaz
            myArticoloA.IdRipiano = myArticolo.IdRipiano
            myArticoloA.IdScaff = myArticolo.IdScaff
            myArticoloA.IdSett = myArticolo.IdSett
            myArticoloA.Modello = myArticolo.Modello
            myArticoloA.nCosto = myArticolo.nCosto 
            myArticoloA.nPrezzo2 = myArticolo.nPrezzo2
            myArticoloA.PrezzoIVA = myArticolo.PrezzoIVA
            myArticoloA.Qty = myArticolo.Qty
            myArticoloA.sMarca = myArticolo.sMarca
            myArticoloA.UM = myArticolo.UM
            myArticoloA.Articolo = myArticolo.Articolo
           
            ListaArticoli.Add(myArticoloA)
 
Upvote 0

LowHZ

New Member
Licensed User
It looks like the class that i add to the list is binded to the list
for example
myarticolo.id= 10
myarticolo.title="asdsda"
myarticolo.etc etc...

B4X:
ListaArticoli.Add(myArticolo)   
myArticolo.Initialize

if i run this code in the list i'll get the list something like this:
List.get(0) = [myarticolo.id=null]
[myarticolo.title=null]
[etc..=null]

instead of this it should show this:

List.get(0) = [myarticolo.id=10]
[myarticolo.title="asdsda"]
[etc..="values...etc"]
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…