b4a 在代码中插入定时器
b4a Insert Timer in a code
我是法国人,很抱歉我的英语不好,我尽力了...
我尝试调用一个名为 timer1_tick 的子程序,我希望它停止我的子程序 "b_reponse1_click"。问题是我的子不等到计时器结束...
代码:
Sub Process_Globals
Dim Timer1 As Timer
....
End Sub
Sub Activity_Create(FirstTime As Boolean)
Timer1.Initialize("Timer1", 1000) ' 1000 = 1 second
Timer1.Enabled = True
...
End Sub
Sub b_reponse1_Click
p= p + 1
If b_reponse1.Text = r5 Then
score = score + 1
b_reponse1.Color=Colors.Green
CallSub("",timer1_tick) ' Here i call sub timer1_tick
b_reponse1.Color=Colors.Gray
Else
b_reponse1.Color=Colors.Red
b_reponse1.Color=Colors.Gray
End If
If nbqpassee = 10 Then
Activity.RemoveAllViews
Activity.LoadLayout("lay_main")
Else
CallSub("",loadq)
End If
End Sub
Timer1 倒计时但我的子 b_reponse1_Click 继续执行而不等待计时器结束
定时器:
代码:
Sub timer1_tick
t = t + 1
Log(t)
End Sub
我试过了,但没有解决我的问题:
代码:
Sub timer1_tick
t = t + 1
Log(t)
timer1.Enabled = False
End Sub
你知道我怎样才能让我的子 b_reponse1_click 停止大约 1 秒吗?
提前感谢您的回答!
timer1_tick 和其他子程序一样是一个常规子程序。不会导致代码执行等待
在论坛中搜索 CallSubPlus。您可以将当前的 sub 分成两个 sub,然后使用 CallSubPlus 调用第二个 sub,它将在指定时间后 运行。
我是法国人,很抱歉我的英语不好,我尽力了...
我尝试调用一个名为 timer1_tick 的子程序,我希望它停止我的子程序 "b_reponse1_click"。问题是我的子不等到计时器结束...
代码:
Sub Process_Globals
Dim Timer1 As Timer
....
End Sub
Sub Activity_Create(FirstTime As Boolean)
Timer1.Initialize("Timer1", 1000) ' 1000 = 1 second
Timer1.Enabled = True
...
End Sub
Sub b_reponse1_Click
p= p + 1
If b_reponse1.Text = r5 Then
score = score + 1
b_reponse1.Color=Colors.Green
CallSub("",timer1_tick) ' Here i call sub timer1_tick
b_reponse1.Color=Colors.Gray
Else
b_reponse1.Color=Colors.Red
b_reponse1.Color=Colors.Gray
End If
If nbqpassee = 10 Then
Activity.RemoveAllViews
Activity.LoadLayout("lay_main")
Else
CallSub("",loadq)
End If
End Sub
Timer1 倒计时但我的子 b_reponse1_Click 继续执行而不等待计时器结束
定时器:
代码:
Sub timer1_tick
t = t + 1
Log(t)
End Sub
我试过了,但没有解决我的问题:
代码:
Sub timer1_tick
t = t + 1
Log(t)
timer1.Enabled = False
End Sub
你知道我怎样才能让我的子 b_reponse1_click 停止大约 1 秒吗?
提前感谢您的回答!
timer1_tick 和其他子程序一样是一个常规子程序。不会导致代码执行等待
在论坛中搜索 CallSubPlus。您可以将当前的 sub 分成两个 sub,然后使用 CallSubPlus 调用第二个 sub,它将在指定时间后 运行。