Hello
I have a list of panel
on each panel I put a canvas
This function creates a new panel with 5 labels and I init a canvas on this panel
The problem is I have the impression that he writes everything in duplicate.
I click on a panel and I want to change the color of panel to show that it is selected it does not work and if I change the value of a label I have a double display, the old value and the new one as if he wrote twice the same label in the panel
if i remove canvas.refresh not problem except that the canvas is not drawn
can3 is a global variable
I have a list of panel
on each panel I put a canvas
This function creates a new panel with 5 labels and I init a canvas on this panel
The problem is I have the impression that he writes everything in duplicate.
I click on a panel and I want to change the color of panel to show that it is selected it does not work and if I change the value of a label I have a double display, the old value and the new one as if he wrote twice the same label in the panel
if i remove canvas.refresh not problem except that the canvas is not drawn
can3 is a global variable
B4X:
Sub AddLineList(text1 As String,text2 As String,text3 As String,text4 As String,text5 As String,deviceid As Int,output As Int)
Dim panel As Panel
Dim left As Int
Dim width As Int
Dim nbr As Int
Dim top As Int
Dim height As Int
height = 40dip
nbr = ScrollView2.Panel.NumberOfViews
panel.Initialize("selectline")
top =( (nbr) * (height+3dip))+5dip
Dim label1 As Label
Dim label2 As Label
Dim label3 As Label
Dim label4 As Label
Dim label5 As Label
label1.Initialize("")
label2.Initialize("")
label3.Initialize("")
label4.Initialize("")
label5.Initialize("")
' btn.Initialize("")
label1.Text = text1
label2.Text = text2
label3.Text = text3
label4.Text = text4
label5.Text = text5
label1.textColor = Colors.white
label2.textColor = Colors.white
label3.textColor = Colors.white
label4.textColor = Colors.white
label5.textColor = Colors.white
If (Main.Istablet = True) Then
Dim Font1 As Font = Font.CreateNew(16)
Else
Dim Font1 As Font = Font.CreateNew(12)
End If
label1.font =Font1
label2.font =Font1
label3.font =Font1
label4.font =Font1
label5.font =Font1
label2.TextAlignment = label2.ALIGNMENT_CENTER
label3.TextAlignment = label3.ALIGNMENT_CENTER
label4.TextAlignment = label4.ALIGNMENT_CENTER
label5.TextAlignment = label4.ALIGNMENT_CENTER
Dim info(4) As Int
info(0) = deviceid
info(1) = output
info(2) = nbr+1
info(3) = text5
panel.Color = Main.colorDark
panel.Tag = info
Dim widthscroll As Int
widthscroll= ScrollView2.Width
If (Main.Istablet = True) Then
left = 5
width = (widthscroll/7)*2.5
panel.AddView(label1,left,3,(widthscroll/7)*2.5,height)
left = left + width
width = ((widthscroll)/7)*1
panel.AddView(label2,left,3,width,height)
left = left + width
width = ((widthscroll)/7)*1
panel.AddView(label3,left,3,width,height)
left = left + width
width = ((widthscroll)/7)*1.5
panel.AddView(label4,left,3,width,height)
left = left + width
width = ((widthscroll)/7)*1
panel.AddView(label5,left,0dip,width,40)
Else
left = 3dip
width = ((ScrollView2.Width)/7)*2.5
panel.AddView(label1,left,0dip,((ScrollView2.Width)/7)*2.5,height)
left = left + width
width = ((ScrollView2.Width)/7)*1
panel.AddView(label2,left,0,width,height)
left = left + width
width = ((ScrollView2.Width)/7)*1
panel.AddView(label3,left,0,width,height)
left = left + width
width = ((ScrollView2.Width)/7)*1.2
panel.AddView(label4,left,0,width,height)
left = left + width
width = ((ScrollView2.Width)/7)*1.25
panel.AddView(label5,left,0dip,width,40)
End If
panel.SetBorder(0,Colors.Black,7)
ScrollView2.Panel.AddView(panel,0dip,top,ScrollView2.Width,height)
ScrollView2.ContentHeight = ((nbr+1)*(height+3dip))+5dip
can3.Initialize(panel)
can3.DrawLine(title1.left + title1.Width+1-ScrollView2.left,0,title1.left + title1.Width+1-ScrollView2.left,height,Colors.RGB(0x33,0x33,0x33),1dip)
can3.DrawLine(title2.left + title2.Width+1-ScrollView2.left,0,title2.left + title2.Width+1-ScrollView2.left,height,Colors.RGB(0x33,0x33,0x33),1dip)
can3.DrawLine(title3.left + title3.Width+1-ScrollView2.left,0,title3.left + title3.Width+1-ScrollView2.left,height,Colors.RGB(0x33,0x33,0x33),1dip)
can3.DrawLine(title4.left + title4.Width+1-ScrollView2.left,0,title4.left + title4.Width+1-ScrollView2.left,height,Colors.RGB(0x33,0x33,0x33),1dip)
can3.Refresh
End Sub