我如何在android工作室中写作:如果条件为真至少5秒,那么做点什么

  • 本文关键字:5秒 条件 android 工作室 如果 android
  • 更新时间 :
  • 英文 :


下面是我当前的代码。然而,问题是图像一直在闪烁

CountDownTimer mCountDownTimer  = new CountDownTimer(5000, 1000) {
public void onTick(long millisUntilFinished){}
public void onFinish() {
image1.setVisibility(View.VISIBLE);
}
};
if (dan > -1) {
mCountDownTimer.start();
} else {
image1.setVisibility(View.GONE);
mCountDownTimer.cancel();
}
var isFalseAfterDelay = false
if (!isFalseAfterDelay) {
isFalseAfterDelay = true//this will be true till 5 sec then it will false
Handler().postDelayed( {
isFalseAfterDelay = false
},5000)// this will delay your operation for 5 sec
}

相关内容

最新更新