Android Question ? CustomListView with different timers

GMan

Well-Known Member
Licensed User
Longtime User
Hoi friends,
i am using the customlistview class for a small app for my model trains to measure and save the time datas the locos are running (reason is that every model has a approx. "running time" before a service like oil etc. must been made).
So i am using this layout:


When i click on the CheckBox, a timer has to start (if true, it has to read saved data for that loco) and append the running time until the checkbox is un-checked.

When i check an box, a message apperas with loco datas and the depending item label textcolor turns red (otherwise white)

But: i have no idea how to start - have i to use (different) timers and if true, how i can set them up ?
I'm sure, someone has "the idea"
 

eps

Expert
Licensed User
Longtime User
Surely you just need to store a start and end time and possibly in a database or in a file or similar? Then use the start and end time to work out the duration. Are you saying you want the duration to update in the view? That would require separate variables.
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Thx 4 u quick reply - it isnt really necessary to update the timers in the layout on runtime.
A database shouldnt be used, only one textfile for every loco in which some datas (loco number, digital adress etc. ) AND in the last row of each file the total running time should be stored.
 
Upvote 0

GMan

Well-Known Member
Licensed User
Longtime User
Creating and using ONE timer is not the problem - but here i have to start the Timer(s) depending on the Index of the CustomListView item.
With this i have absolutly problems qith getting it in the "MasterControlUnit"

Here is the part from the CustomListView example which handles the CheckBox_Change routine. The TimerTick Event is also still empty because...(see above):

B4X:
Sub chk_CheckedChange(Checked As Boolean)
    Dim index As Int
    index = clv3.GetItemFromView(Sender)
    Dim pnl As Panel
    pnl = clv3.GetPanel(index)
    Dim zeittext As EditText
    zeittext = pnl.GetView (2)
    Dim chk As CheckBox
    chk = pnl.GetView(3)
    Dim lbl As Label
    lbl = pnl.GetView(0)
   
    If chk.Checked = True Then
    lbl.Textcolor = Colors.Red
    ' part for LocoTimer1 START
    '...
        Else
    lbl.Textcolor = Colors.White
    ' part for LocoTimer1 STOP
    ' ...
    End If
       
    Msgbox("Lokomotive: " & clv3.GetValue(index) & CRLF & "Aktiv: " & chk.Checked & CRLF & "Gesamtzeit: " & zeittext.text, "")
End Sub
Sub LocoTimer1_Tick
    ' ...   
End Sub

Without having any knowledge about how to start the enchilada it makes no sense with Try&Error
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…