我想在倒数计时器结束后执行beginrecording()
方法。但是这两种方法是同时执行的。谁能帮我解决这个问题。
我的代码如下:
StartBtn.setOnClickListener(new OnClickListener() {
public void onClick(View view)
{
//setContentView(textState);
MyCount counter = new MyCount(6000, 1000, textState);
StartBtn.setVisibility(4);
counter.start();
try
{
// Thread.sleep(2000);
beginRecording();
EndBtn.setVisibility(0);
}
catch(Exception e)
{
e.printStackTrace();
}
}
});
提前致谢
最佳答案
什么是MyCount
?是Timer
吗?
也许你应该尝试这样的事情
int i = 0;
Timer timer = new Timer(1000, new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (i == 100){ //-------- When you want to stop timer and start your function
timer.stop();
try{
// Thread.sleep(2000);
beginRecording();
EndBtn.setVisibility(0);
} catch(Exception e){
e.printStackTrace();
}
}
i = i + 1;
}
});
timer.start();
希望这可以帮助。