Hi there
Firstly I would like to thank Erel for B4X as well as all developers who are willing to help others.
I'm having a challenge which I hope you can assist with. I'm developing a POS app and I can't seem to get it to work as expected on the sales side. The app uses a dedicated PDA scanning device for scanning barcodes of products. After scanning a barcode, the app searches local SQLite database for products. When it finds it, it adds the product info into a custom list view. As users are scanning barcodes, products are added to he CLV. So far this works well.
In my layout I have a Product label, 2 buttons (Plus and Minus) plus an Edittext and a total label. Through the edittext, users are able to type in the quantity manually or they can use buttons to increase or decrease the quantity. In the total label, quantity and price are multiplied and displayed. So far so good.
My challenge is on manipulating the quantities of the items. After scanning the product, I press plus to increase the quantity or minus to decrease the quantity. After scanning the second product use the buttons likewise and it works. However, when I try to change the quantity of the first product by pressing the buttons in the CLV, it changes the edittext of the second product. I add more products and whenever I press buttons on the previous products, it always changes the edittext of the last item in the CLV.
Just checking the index etc...
Logs...
My edittext only works on the last product in the CLV, irrespective of which button I press.
Please help. I'm stuck here...
Firstly I would like to thank Erel for B4X as well as all developers who are willing to help others.
I'm having a challenge which I hope you can assist with. I'm developing a POS app and I can't seem to get it to work as expected on the sales side. The app uses a dedicated PDA scanning device for scanning barcodes of products. After scanning a barcode, the app searches local SQLite database for products. When it finds it, it adds the product info into a custom list view. As users are scanning barcodes, products are added to he CLV. So far this works well.
Adding products to CLV:
Dim p As Panel = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Root.Width, 130dip)
p.LoadLayout("Layout_Sales_View")
lblProd_Name.Text = Product_Name
Dim prod_list As List
prod_list.Initialize
prod_list.AddAll(Array As String(CLV_Product_Code, Sale_ID, CLV_Product_Name , CLV_Product_Price, CLV_Product_QTY, CLV_Line_Total))
clvProduct_Sales.Add(p,prod_list)
In my layout I have a Product label, 2 buttons (Plus and Minus) plus an Edittext and a total label. Through the edittext, users are able to type in the quantity manually or they can use buttons to increase or decrease the quantity. In the total label, quantity and price are multiplied and displayed. So far so good.
Pressing Plus or Minus Buttons:
If IsNumber(txtEnterQTY.Text) Then
Product_QTY = txtEnterQTY.Text
Else
Product_QTY = 0
End If
Product_QTY = Product_QTY + 1 ' Increase quantity by 1
txtEnterQTY.Text = Product_QTY ' Update EditText
Line_Total = Product_QTY*Product_Price
lblLine_Total.Text = f.Format(Line_Total)
My challenge is on manipulating the quantities of the items. After scanning the product, I press plus to increase the quantity or minus to decrease the quantity. After scanning the second product use the buttons likewise and it works. However, when I try to change the quantity of the first product by pressing the buttons in the CLV, it changes the edittext of the second product. I add more products and whenever I press buttons on the previous products, it always changes the edittext of the last item in the CLV.
Just checking the index etc...
Checking Index in Plus, Minus Buttons:
Dim index As Int = clvProduct_Sales.GetItemFromView(Sender)
Dim p As B4XView = clvProduct_Sales.GetPanel(index)
Dim pp As B4XView = p.GetView(0)
Log("Button Plus index = " & index)
Log("p = " & p)
Log("pp = " & pp)
Logs...
B4X:
Button Plus index = 0
p = (BALayout): Left=0, Top=0, Width=720, Height=248
pp = (TextView): Left=19, Top=19, Width=519, Height=96, Tag=
My edittext only works on the last product in the CLV, irrespective of which button I press.
Please help. I'm stuck here...