Android Question ACswich CheckedChange

vbmundo

Well-Known Member
Licensed User
Hi,

are any way to skip the CheckedChange Event every time that on ACSwich appear ?

I have this code

B4X:
Sub CargoLista
    Dim i As Int
    CLVSeteos.Clear
    For i = 0 To 9
        CLVSeteos.Add(CreateListItem(i, CLVSeteos.AsView.Width, 90dip), 90dip, 0)
    Next
End Sub
Sub CreateListItem(Item As Int, Width As Int, Height As Int) As Panel
    Dim p As Panel, Pn As Int
    p.Initialize("")
    Activity.AddView(p, 0, 0, Width, Height)
    Pn=Item+1
    p.LoadLayout("Seteo_" & NumberFormat(Pn,1,0))
    Select Item
        Case 0
            lbl_ValorTemaDefault.text=""
            If Valor_TemaDefault.Trim.Length>0 Then lbl_ValorTemaDefault.text=Funciones.TraigoNombreTema(Valor_TemaDefault)
            LblSeteo_1.Text=Funciones.Traducir("Tono Default")
        Case 1 
            Switch2.Checked=Valor_RepetirDefault
              LblSeteo_2.Text=Funciones.Traducir("Posponer Default")

And in the CheckedChange Event this code

B4X:
Sub Switch2_CheckedChange(Checked As Boolean)
    Valor_RepetirDefault=Checked
End Sub

I need to set the Variable "Valor_RepetirDefault" with every click in the ACSwich, but when avery panel is load in the CustomListView the ACSwich launch this event again turning on or off this value.

How can I avoid this event and only use when the user Click this control.

Regards
 

vbmundo

Well-Known Member
Licensed User
I found a solution with BOOLEAN variable.

In CreateListItem Sub , I put in TRUE a "Loading" Variable, and when all panels are loaded I turn to FALSE.

And in the EVENT SUB I put this.

B4X:
    If Loading=False Then Valor_RepetirDefault=Switch2.Checked
 
Upvote 0
Top