Android账号注册实现点击获取验证码倒计时效果

Android账号注册实现点击获取验证码倒计时效果,第1张

概述网站中为了防止恶意获取验证短信、验证邮箱,都会在点击获取验证码的按钮上做个倒计时的效果,如何实现这个效果,具体内容如下

网站中为了防止恶意获取验证短信、验证邮箱,都会在点击获取验证码的按钮上做个倒计时的效果,如何实现这个效果,具体内容如下

效果图:

 

代码:

Registeractivity.java

import androID.os.Bundle;import androID.support.v7.Widget.Toolbar;import androID.vIEw.VIEw;import androID.Widget.button;import com.jialianjia.bzw.BaseActivity;import com.jialianjia.bzw.R;import com.jialianjia.bzw.utils.CountDownbuttonHelper;import com.lIDroID.xutils.VIEwUtils;import com.lIDroID.xutils.vIEw.annotation.VIEwInject;/** * 注册功能 * Created by GXS on 2016/4/21. */public class Registeractivity extends BaseActivity{ private button btn_yzm; @VIEwInject(R.ID.toolbar) Toolbar toolbar; @OverrIDe protected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_register); VIEwUtils.inject(this); initToolbar(toolbar,"账号注册",true); // 获取验证码--start btn_yzm = (button) findVIEwByID(R.ID.btn_yzm); btn_yzm.setonClickListener(new VIEw.OnClickListener() {  @OverrIDe  public voID onClick(VIEw v) {  CountDownbuttonHelper helper = new CountDownbuttonHelper(btn_yzm,"倒计时",60,1);  helper.setonFinishListener(new CountDownbuttonHelper.OnFinishListener() {   @OverrIDe   public voID finish() {   // Toast.makeText(Registeractivity.this,"倒计时结束",Toast.LENGTH_SHORT).show();   btn_yzm.setText("再次获取");   }  });  helper.start();  } }); // 获取验证码--end }}

布局文件:

activity_register.xml

<?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical"> <androID.support.v7.Widget.Toolbar androID:ID="@+ID/toolbar" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:background="?attr/colorPrimary" androID:theme="@style/Apptheme.AppbarOverlay" androID:fitsSystemwindows="true" /> <linearLayout androID:layout_height="50dp" androID:layout_wIDth="match_parent" androID:layout_margintop="10dp" androID:layout_marginRight="10dp" androID:layout_marginleft="10dp" androID:background="@color/white" androID:orIEntation="horizontal"> <TextVIEw  androID:ID="@+ID/tv_phone"  androID:layout_wIDth="60dp"  androID:layout_height="wrap_content"  androID:text="@string/tv_info_phone"  androID:layout_margin="8dp"  androID:textcolor="@color/black"  androID:layout_gravity="center_vertical"  androID:textSize="17sp"/> <EditText  androID:ID="@+ID/et_phone"  androID:layout_wIDth="190dp"  androID:layout_height="35dp"  androID:layout_toRightOf="@ID/tv_phone"  androID:background="@null"  androID:hint="@string/edt_phone_tips"  androID:maxLength="20"  androID:layout_gravity="center_vertical"  androID:singleline="true"  androID:textSize="16sp" /> <VIEw  androID:layout_wIDth="2px"  androID:layout_height="50dp"  androID:background="@color/driverline" /> <button  androID:ID="@+ID/btn_yzm"  androID:layout_wIDth="wrap_content"  androID:layout_height="50dp"  androID:layout_marginleft="3dp"  androID:layout_gravity="center"  androID:background="@color/white"  androID:text="@string/btn_yzm_text"/> </linearLayout> <VIEw androID:ID="@+ID/vIEw_line" androID:layout_wIDth="match_parent" androID:layout_height="1dp" androID:layout_below="@ID/tv_phone" androID:layout_marginleft="10dp" androID:layout_marginRight="10dp" androID:background="@color/driverline" /> <linearLayout androID:layout_height="50dp" androID:layout_wIDth="match_parent" androID:layout_margintop="10dp" androID:layout_marginRight="10dp" androID:layout_marginleft="10dp" androID:background="@color/white" androID:orIEntation="horizontal"> <TextVIEw  androID:ID="@+ID/tv_yzm"  androID:layout_wIDth="60dp"  androID:layout_height="wrap_content"  androID:text="@string/tv_yzm_text"  androID:layout_margin="8dp"  androID:textcolor="@color/black"  androID:layout_gravity="center_vertical"  androID:textSize="17sp"/> <EditText  androID:ID="@+ID/et_yzm"  androID:layout_wIDth="190dp"  androID:layout_height="35dp"  androID:layout_toRightOf="@ID/tv_phone"  androID:background="@null"  androID:hint="@string/edt_yzm_tips"  androID:maxLength="20"  androID:layout_gravity="center_vertical"  androID:singleline="true"  androID:textSize="16sp" /> </linearLayout> <VIEw androID:ID="@+ID/vIEw_line1" androID:layout_wIDth="match_parent" androID:layout_height="1dp" androID:layout_below="@ID/tv_phone" androID:layout_marginleft="10dp" androID:layout_marginRight="10dp" androID:background="@color/driverline" /> <linearLayout androID:layout_height="50dp" androID:layout_wIDth="match_parent" androID:layout_margintop="10dp" androID:layout_marginRight="10dp" androID:layout_marginleft="10dp" androID:background="@color/white" androID:orIEntation="horizontal"> <TextVIEw  androID:ID="@+ID/tv_password"  androID:layout_wIDth="60dp"  androID:layout_height="wrap_content"  androID:text="@string/tv_password_text"  androID:layout_margin="8dp"  androID:textcolor="@color/black"  androID:layout_gravity="center_vertical"  androID:textSize="17sp"/> <EditText  androID:ID="@+ID/et_password"  androID:layout_wIDth="190dp"  androID:layout_height="35dp"  androID:layout_toRightOf="@ID/tv_phone"  androID:background="@null"  androID:hint="@string/edt_password_text"  androID:maxLength="20"  androID:layout_gravity="center_vertical"  androID:singleline="true"  androID:textSize="16sp" /> </linearLayout> <VIEw androID:ID="@+ID/vIEw_line2" androID:layout_wIDth="match_parent" androID:layout_height="1dp" androID:layout_below="@ID/tv_phone" androID:layout_marginleft="10dp" androID:layout_marginRight="10dp" androID:background="@color/driverline" /> <button androID:ID="@+ID/btn_regist" androID:layout_wIDth="match_parent" androID:layout_height="45dp" androID:layout_margintop="30dp" androID:layout_marginleft="10dp" androID:layout_marginRight="10dp" androID:background="@drawable/btn_select" androID:gravity="center" androID:padding="5dp" androID:text="@string/btn_regist_text" androID:textcolor="@color/white" androID:textSize="16sp" /></linearLayout>

以上就是本文的全部内容,希望能给大家一个参考,也希望大家多多支持编程小技巧。

总结

以上是内存溢出为你收集整理的Android账号注册实现点击获取验证码倒计时效果全部内容,希望文章能够帮你解决Android账号注册实现点击获取验证码倒计时效果所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1141845.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-31
下一篇 2022-05-31

发表评论

登录后才能评论

评论列表(0条)

保存