B4X:
Sub clv1_ItemClick (Index As Int, Value As Object)
Dim pnl As Panel = clv1.GetPanel(Index)
Dim lbl As Label = pnl.GetView(4)
If G = 0 Then
Activity.AddView(panel2, 0, 60dip, pnl.Width, pnl.Height)
G = 1
End If
panel2.RemoveAllViews
vartomada = lbl.Text
pnl.RemoveView
clv1.AsView.Top = 210dip
If bandera = 0 Then
clv1.AsView.Height = clv1.AsView.Height - 180dip
bandera = 1
End If
pnl.GetView(6).Visible = False
pnl.getview(5).Visible = False
panel2.AddView(pnl, 0 , 0, 100%y, 100%x)
clv1.Clear
cargarvar
End Sub
In my code I take a panel of the CLV and I add it in the top, then I take a value of the label of the selected panel (price of the product) I compare it with all the prices of all the CLV item and if it is higher or lower than the selected one , To make visible a label with the difference between the prices but to add an image (up arrow or down arrow) my code works perfectly, but filling again the CVL with a SQL query.
B4X:
Sub cargarvar
ProgressDialogHide
Dim cmd As DBCommand
cmd.Initialize
cmd.Name = a
reqManager.ExecuteQuery(cmd, 0, "select")
End Sub
B4X:
Case "select"
Dim result As DBResult = reqManager.HandleJob(job)
For Each records() As Object In result.Rows
Dim a1,a2,a3,a4,a5,a6,a7 As String
Dim buffer() As Byte
buffer = records(result.Columns.Get("imagen"))
a1 = records(result.Columns.Get("lote"))
a2= records(result.Columns.Get("nombre"))
a3 = records(result.Columns.Get("gramaje"))
a4 = records(result.Columns.Get("precio"))
a5 = records(result.Columns.Get("leche"))
a6 = records(result.Columns.Get("azucar"))
a7 = records(result.Columns.Get("instantaneo"))
p.Initialize("")
p2.Initialize("")
Activity.AddView(p,0,0,100%y,100%x)
p.LoadLayout("2")
p.RemoveView
img.Bitmap = reqManager.BytesToImage(buffer)
Label1.Text = a1
label2.Text = a2
label3.Text = a3&"Gr"
label4.Text = a4
convert = a4
convert = NumberFormat2(a4,0,2,2,True)
Label12.Text = convert
If a5 = 1 Then
ck1.Bitmap = bitmap7
Else
ck1.Bitmap = bitmap8
End If
'
If a6 = 1 Then
ck2.Bitmap = bitmap7
Else
ck2.Bitmap = bitmap8
End If
'
If a7 = 1 Then
ck3.Bitmap = bitmap7
Else
ck3.Bitmap = bitmap8
End If
If vartomada < a4 Then
label5.Text = a4-vartomada
label5.Text = NumberFormat2(label5.Text,0,2,2,True)
End If
If vartomada < a4 Then
ImageView2.Bitmap = bitmap4
End If
If vartomada > a4 Then
label5.Text = vartomada-a4
label5.Text = NumberFormat2(label5.Text,0,2,2,True)
End If
If vartomada > a4 Then
ImageView2.Bitmap = bitmap5
End If
clv1.Add(p,p.Height,"")
Next
End Select
I can not find the way to take the panel, remove it from the CLV, take it to the top, take the value of the label (4), compare the value of the label (4) with all tags (4) of all panels, modify all CLV panels, put visible images or assign it, and if you click again take the top panel add it to CLV in x position, and perform the above procedure. All this in order not to perform the SQL query again and fill the CLV.
Thanks in advance.
Post: In its defect as it is already loaded the CLV to work with him to modify its values in relation to the clicked one
Last edited: