嗨,我正在制作体育倒计时计时器,我想暂停和恢复它。但我不会在公共场合这么做,因为我的倒计时很复杂。我在这里粘贴代码,它是简单的倒计时,这样你就有代码,你可以尝试做它
public class MainActivity extends AppCompatActivity {
Button btn1, btn2, btn3;
TextView tv1, tv2;
int czasrundy = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv1 = findViewById(R.id.textView);
tv2 = findViewById(R.id.textView20);
btn1 = findViewById(R.id.pausebutton);
btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
CountDownTimer countDownTimer = new CountDownTimer(4000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
tv1.setText(""+millisUntilFinished);
}
@Override
public void onFinish() {
}
}
}
});
}
}
暂无答案!
目前还没有任何答案,快来回答吧!