xicode
New Member
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim tmr As Timer
Dim remainingSeconds As Int
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ImageView1 As ImageView
Private cb1smg1 As CheckBox
Private cb2smg1 As CheckBox
Private cb3smg1 As CheckBox
Private cb4smg1 As CheckBox
Dim timerTextView As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("SM_GamePlay1")
' Initialize the tmr timer
tmr.Initialize("tmr", 1000) 'Tick every second (1000 milliseconds)
tmr.Enabled = True
remainingSeconds = 15
' Attempt to get the EditText with ID "timerTextView"
timerTextView = Activity.GetView("timerTextView")
If timerTextView = Null Then
Log("Error: timerTextView not found in layout!")
End If
End Sub
Sub tmr_Tick
'Update the TextView with the remaining time
timerTextView.Text = "Timer: " & remainingSeconds & " seconds"
'Decrement remaining time
remainingSeconds = remainingSeconds - 1
'Stop the Timer when countdown reaches 0
If remainingSeconds = 0 Then
tmr.Enabled = False
Log("Timer finished!")
'Add any code to execute after timer finishes
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub cb4smg1_CheckedChange(Checked As Boolean)
If Checked Then
cb4smg1.Color = Colors.Red
Else
cb4smg1.Color = 0XFF11DBB2
End If
End Sub
Private Sub cb3smg1_CheckedChange(Checked As Boolean)
If Checked Then
cb3smg1.Color = Colors.Red
Else
cb3smg1.Color = 0XFF11DBB2
End If
End Sub
Private Sub cb2smg1_CheckedChange(Checked As Boolean)
If Checked Then
cb2smg1.Color = Colors.Red
Else
cb2smg1.Color = 0XFF11DBB2
End If
End Sub
Private Sub cb1smg1_CheckedChange(Checked As Boolean)
If Checked Then
cb1smg1.Color = Colors.Red
Else
cb1smg1.Color = 0XFF11DBB2
End If
End Sub
Private Sub timerTextView_TextChanged (Old As String, New As String)
If remainingSeconds > 0 Then
timerTextView.Text = "Timer: " & remainingSeconds & " seconds"
Else
timerTextView.Text = "Timer: Time's up!"
End If
End Sub
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim tmr As Timer
Dim remainingSeconds As Int
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ImageView1 As ImageView
Private cb1smg1 As CheckBox
Private cb2smg1 As CheckBox
Private cb3smg1 As CheckBox
Private cb4smg1 As CheckBox
Dim timerTextView As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("SM_GamePlay1")
' Initialize the tmr timer
tmr.Initialize("tmr", 1000) 'Tick every second (1000 milliseconds)
tmr.Enabled = True
remainingSeconds = 15
' Attempt to get the EditText with ID "timerTextView"
timerTextView = Activity.GetView("timerTextView")
If timerTextView = Null Then
Log("Error: timerTextView not found in layout!")
End If
End Sub
Sub tmr_Tick
'Update the TextView with the remaining time
timerTextView.Text = "Timer: " & remainingSeconds & " seconds"
'Decrement remaining time
remainingSeconds = remainingSeconds - 1
'Stop the Timer when countdown reaches 0
If remainingSeconds = 0 Then
tmr.Enabled = False
Log("Timer finished!")
'Add any code to execute after timer finishes
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Private Sub cb4smg1_CheckedChange(Checked As Boolean)
If Checked Then
cb4smg1.Color = Colors.Red
Else
cb4smg1.Color = 0XFF11DBB2
End If
End Sub
Private Sub cb3smg1_CheckedChange(Checked As Boolean)
If Checked Then
cb3smg1.Color = Colors.Red
Else
cb3smg1.Color = 0XFF11DBB2
End If
End Sub
Private Sub cb2smg1_CheckedChange(Checked As Boolean)
If Checked Then
cb2smg1.Color = Colors.Red
Else
cb2smg1.Color = 0XFF11DBB2
End If
End Sub
Private Sub cb1smg1_CheckedChange(Checked As Boolean)
If Checked Then
cb1smg1.Color = Colors.Red
Else
cb1smg1.Color = 0XFF11DBB2
End If
End Sub
Private Sub timerTextView_TextChanged (Old As String, New As String)
If remainingSeconds > 0 Then
timerTextView.Text = "Timer: " & remainingSeconds & " seconds"
Else
timerTextView.Text = "Timer: Time's up!"
End If
End Sub