而不是计时器以毫秒为单位。如何让这个30秒计时器从1-30开始?这是我到目前为止所拥有的。我必须将长整数转换为整数吗?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_countdown);
buttonStart = (Button)findViewById(R.id.start);
textCounter = (TextView)findViewById(R.id.counter);
buttonStart.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
myCountDownTimer = new MyCountDownTimer(30000, 1000);
myCountDownTimer.start();
}});
}
public class MyCountDownTimer extends CountDownTimer {
public MyCountDownTimer(long millisInFuture, long countDownInterval) {
super(millisInFuture, countDownInterval);
}
@Override
public void onTick(long millisUntilFinished) {
textCounter.setText(String.valueOf(millisUntilFinished));
}
@Override
public void onFinish() {
textCounter.setText("Finished");
}