Android Question [SOLVED] Issue with insertAt in List

Dianzoa

Active Member
Licensed User
I have a For loop, and I do and InsertAt on every item of the For, inside the loop itself, I can see that the correct values got added. But outside of the loop all values are the same in the list, somehow only the last item of the loop got replicated on all items in the list
B4X:
        For i = 0 To rows.Size - 1
                Dim m As Map
                m = rows.Get(i)
          
                pedidoCab.name = m.Get("name")
                pedidoCab.direccion = m.get("direccion")
                pedidoCabeceraSolicitado.InsertAt(i,pedidoCab)
                MsgboxAsync(pedidoCabeceraSolicitado.Get(i),"En el for")
                pedidosDetalleTarjetaSolicitados.Add(CreateItemPedidoCabSolicitado(pedidosDetalleTarjetaSolicitados.AsView.Width,Main.idpedido,nombreCliente,direccionLocal,estadoPedido,fecha),"")
                          
            Next
 
Last edited:

Dianzoa

Active Member
Licensed User
You're adding that "pdidoCab" (???) every time.
Actually if you look above that, that variable got assigned new values on each iteration
m = rows.Get(i)
pedidoCab.name = m.Get("name")
pedidoCab.direccion = m.get("direccion")
 
Upvote 0
Top