Bruno Ramos
Member
Hello there, I've a problem here. Look I have to work with buttons in my xCustomListView, I have a list with products where there are two buttons, one for add products to the cart and the other for remove ones, but when I touch one button in a random item does not change the specific product, only change the last item. How can I solve it?
For instance, in this case I touch the button which is indicated and only change the last item. My code is it:
For instance, in this case I touch the button which is indicated and only change the last item. My code is it:
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("General")
ListaProductos.Initialize
ListaProductos.Add(CreateMap("nombre":"Harina COLOLO 0000 X 1kg", "marca":"COLOLO", "comercio":"El Vasco", "precio":90, "unidad":1, "imagen": LoadBitmap(File.DirAssets , "harina cololo.jpg")))
ListaProductos.Add(CreateMap("nombre":"Alfajor Clásico PORTEZUELO chocolate", "marca":"PORTEZUELO", "comercio":"El Vasco", "precio":15, "unidad":1, "imagen": LoadBitmap(File.DirAssets , "alfajor.jpg")))
ListaProductos.Add(CreateMap("nombre":"Aceite OPTIMO de girasol X 1lt ", "marca":"OPTIMO", "comercio":"El Vasco", "precio":45, "unidad":1, "imagen": LoadBitmap(File.DirAssets , "aceite.jpg")))
ListaProductos.Add(CreateMap("nombre":"Arroz blanco SAMAN X 1kg", "marca":"SAMAN", "comercio":"El Vasco", "precio":50, "unidad":1, "imagen": LoadBitmap(File.DirAssets , "arroz.jpg")))
Dim xui As XUI
For Each newArt As Map In ListaProductos
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0,0, clv.AsView.Width, 190dip)
p.LoadLayout("Producto_Super1") 'layout has 5 labels
nombre.Text = newArt.Get("nombre")
marca.Text ="Marca: " & newArt.Get("marca")
comercio.Text = "Comercio: " & newArt.Get("comercio")
precio.Text = "$" & newArt.Get("precio")
unidad.Text = newArt.Get("unidad") & " un."
imagen.Bitmap = newArt.Get("imagen")
clv.Add(p, newArt)
Next
End Sub
Sub agregar_Click
For Each newArt As Map In ListaProductos
Dim un As Int = newArt.Get("unidad")
un = un + 1
unidad.Text = newArt.Put("unidad", un) & " un."
Next
End Sub