按钮背景代码中设置和倒计时的使用

xiaoxiao2021-02-28  87

1、按钮背景

//使用src属性时,在代码中修改显示内容btn_start.setImageDrawable(getResources().getDrawable(R.drawable.play));

//使用background属性时,在代码中修改显示内容btn_start.setBackground(getResources().getDrawable(R.drawable.pause));

2、CountDownTimer(t1:总时间,t2:间隔):

在一个TextView不断显示剩下的时间,代码如下:

[java]  view plain  copy   private TextView vertifyView;       private CountDownTimer timer = new CountDownTimer(100001000) {              @Override           public void onTick(long millisUntilFinished) {               vertifyView.setText((millisUntilFinished / 1000) + "秒后可重发");           }              @Override           public void onFinish() {               vertifyView.setEnabled(true);               vertifyView.setText("获取验证码");           }       };  
转载请注明原文地址: https://www.6miu.com/read-71562.html

最新回复(0)