Bruno Ramos
Member
Hello there! I have a question, I want to touch a button with the cart and add the item to a different module where there is a list with the items in the cart. I make this code but when y touch on the button it creates a new item in the active list.
If I touch on the cart button in the last item it create a new item but in the active activity, not in the "Carrito" activity. Something like that:
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.0, "unidad":1.0, "imagen": LoadBitmap(File.DirAssets , "harina cololo.jpg")))
ListaProductos.Add(CreateMap("nombre":"Alfajor Clásico PORTEZUELO chocolate", "marca":"PORTEZUELO", "comercio":"El Vasco", "precio":15.0, "unidad":1.0, "imagen": LoadBitmap(File.DirAssets , "alfajor.jpg")))
ListaProductos.Add(CreateMap("nombre":"Aceite OPTIMO de girasol X 1lt ", "marca":"OPTIMO", "comercio":"El Vasco", "precio":45.0, "unidad":1.0, "imagen": LoadBitmap(File.DirAssets , "aceite.jpg")))
ListaProductos.Add(CreateMap("nombre":"Arroz blanco SAMAN X 1kg", "marca":"SAMAN", "comercio":"El Vasco", "precio":50.0, "unidad":1.0, "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")
unidad.Text = newArt.Get("unidad")
precio.Text = newArt.Get("precio")
imagen.Bitmap = newArt.Get("imagen")
clv.Add(p, newArt)
Next
End Sub
Sub carrito_Click
Dim xui As XUI
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0,0, clv.AsView.Width, 190dip)
p.LoadLayout("Producto_Super1")
nombre.Text = newArt.Get("nombre")
marca.Text ="Marca: " & newArt.Get("marca")
comercio.Text = "Comercio: " & newArt.Get("comercio")
unidad.Text = newArt.Get("unidad")
precio.Text = newArt.Get("precio")
imagen.Bitmap = newArt.Get("imagen")
clv.Add(p, newArt)
End Sub
If I touch on the cart button in the last item it create a new item but in the active activity, not in the "Carrito" activity. Something like that: