Sub Activity_Create(FirstTime As Boolean)
clv1.Initialize(Me, "clv1")
Activity.AddView(clv1.AsView, 0%x, 10%y, 100%x, 90%y)
For i = 1 To 16
clv1.Add(CreateListItem("Relais " & i, clv1.AsView.Width, 50dip), 50dip, "Relais " & i)
Next
End Sub
Sub CreateListItem(Text As String, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.Black
Dim b As Button 'all buttons click events will be handled with Sub Button_Click
b.Initialize("button")
Dim tog As ToggleButton 'all toggle_buttons click events will be handled with Sub Toggle_Button Checked_Change
tog.Initialize("tog")
tog.Checked = False
tog.TextOn = "ON"
tog.TextOff = "OFF"
Dim chk As CheckBox
chk.Initialize("chk")
Dim lbl As Label
lbl.Initialize("lbl")
lbl.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
lbl.Text = Text
lbl.TextSize = 16
lbl.TextColor = Colors.White
b.Text = "Pulse"
p.AddView(lbl, 5dip, 2dip, 150dip, Height - 4dip) 'view #0
p.AddView(b, 155dip, 2dip, 110dip, Height - 4dip) 'view #1
p.AddView(tog, 280dip, 2dip, 60dip, Height - 4dip) 'view #3
Return p
End Sub
Sub lbl_LongClick
Dim index As Int
index = clv1.GetItemFromView(Sender)
Dim lbl As Label
lbl.Initialize("lbl")
' Msgbox(clv1.GetValue(index), "Rename ?")
'Message box
Dim DR As Int
Log("DR=" & DR)
Dim IP As BD_InputBoxParams
IP.Initialize
IP.Question = "<I>Rename Relais 1? </I>"
IP.QuestionTextSize = 18
IP.SpaceBetween = 4dip
IP.InputTextSize = 24
IP.InputType = IP.INPUT_TYPE_TEXT_WITH_CAPS
IP.Gravity = Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL
IP.ValidationCallback = "Input_Validation"
IP.WithSuggestions = True
DR = BD.InputBox("New Name", IP, "OK", "Cancel", "", LoadDrawable("ic_menu_edit"))
Log("DR=" & DR)
If DR = DialogResponse.POSITIVE Then
Log(IP.Answer)
Log(IP.CompactAnswer)
lbl.Text=(IP.Answer) 'not working...
Else
End If
Dim btnOK As Button
btnOK.Initialize("")
btnOK.Background = CreateStateListDrawable
btnOK.Text = "<Font Color='Yellow'>O</Font>K"
btnOK.TextColor = Colors.White
Dim btnCancel As Button
btnCancel.Initialize("")
btnCancel.Text = "<Font Color='Yellow'>C</Font>ancel"
btnCancel.TextColor = Colors.White
btnCancel.Background = CreateStateListDrawable
End Sub