Android工作室如何设置倒计时时间(Android studio how to set time for countdown)

大家好,所以我得到了一个倒计时的代码,但时间设置只有30秒,我需要至少1分钟....我应该改变什么值,让它1分钟? 这是我使用的代码

new CountDownTimer(30000, 1000)
{
public void onTick(long millisUntilFinished)
{
tvTimer.setText("Time remaining : " + millisUntilFinished / 1000);
}
@Override
public void onFinish() {
Intent in = new Intent(getApplicationContext(), Results.class);
in.putExtra("passedCorrect", correct);
in.putExtra("passedWrong", wrong);
in.putExtra("passedMark", marks);
startActivity(in);
}
}.start();
hi guys so i got a code for a countdown but the time set is only for 30 seconds and i need to make it for at least 1 minute.... what value should i change to make it 1 minute? here are the codes i use
new CountDownTimer(30000, 1000)
{
public void onTick(long millisUntilFinished)
{
tvTimer.setText("Time remaining : " + millisUntilFinished / 1000);
}
@Override
public void onFinish() {
Intent in = new Intent(getApplicationContext(), Results.class);
in.putExtra("passedCorrect", correct);
in.putExtra("passedWrong", wrong);
in.putExtra("passedMark", marks);
startActivity(in);
}
}.start();


2020-02-24 16:24

满意答案

改变这一行:

new CountDownTimer(30000, 1000)

至:

new CountDownTimer(60000, 1000)

构造函数中的第一个参数是询问运行之间等待的时间(以毫秒为单位)。

Changes this line:
new CountDownTimer(30000, 1000)
to:
new CountDownTimer(60000, 1000)
The first argument in the Constructor is asking how long to wait (in milliseconds) between runs.

2016-01-08

相关问答

试试这个

var timeInt = undefined;
function setTimer(obj){
if(timeInt != undefined){
clearInterval(timeInt);
}
timeInt = setInterval(function(e){
obj.text = (parseInt(obj.text) + 1);
},1000);
}
var arrRow= [];
$.winIndex.addEventListener("open", fu...

尝试这个 new CountDownTimer(30000, 1000) {//CountDownTimer(edittext1.getText()+edittext2.getText()) also parse it to long

public void onTick(long millisUntilFinished) {
mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
//he...

移动if(index

在你的setTimeout里面你可以重新初始化它。 你有一个叫做event.elapsed东西来检查时间是否已经过去,并且不需要finish.countdown 。 网站示例 工作演示

$(document).ready(function(){
var date='2015/07/29 12:29:00';//change this to very near time and elapse and check it
var format='%D days %H hours %M m...