/*调用一个倒计时的内部类*/ new CountdownTimer(60000, 1000) { public void onTick(long millisUntilFinished) { phone_tv_getphonecode.setText(millisUntilFinished / 1000 + "秒后可重发"); phone_tv_getphonecode.setEnabled(false); phone_tv_agincode.setEnabled(false); } public void onFinish() { phone_tv_getphonecode.setText("获取手机验证码"); phone_tv_getphonecode.setEnabled(true); phone_tv_agincode.setEnabled(true); } }.start();/*定义一个倒计时的内部类*/ public class CountdownTimer extends CountDownTimer { public CountdownTimer(long millisInFuture, long countDownInterval) { super(millisInFuture, countDownInterval); } @Override public void onFinish() { // tv.setText("finish"); } @Override public void onTick(long millisUntilFinished) { // tv.setText("请等待30秒(" + millisUntilFinished / 1000 + ")..."); Toast.makeText(getActivity(), millisUntilFinished / 1000 + "", Toast.LENGTH_LONG).show();//toast有显示时间延迟 } }
倒计时60秒
最新推荐文章于 2021-12-08 09:38:56 发布