国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

Android賬號注冊實(shí)現(xiàn)點(diǎn)擊獲取驗(yàn)證碼倒計時效果

2019-12-12 06:20:19
字體:
供稿:網(wǎng)友

網(wǎng)站中為了防止惡意獲取驗(yàn)證短信、驗(yàn)證郵箱,都會在點(diǎn)擊獲取驗(yàn)證碼的按鈕上做個倒計時的效果,如何實(shí)現(xiàn)這個效果,具體內(nèi)容如下

效果圖:

代碼:

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); // 獲取驗(yàn)證碼--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,"倒計時結(jié)束",Toast.LENGTH_SHORT).show();   btn_yzm.setText("再次獲取");   }  });  helper.start();  } }); // 獲取驗(yàn)證碼--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>

以上就是本文的全部內(nèi)容,希望能給大家一個參考,也希望大家多多支持武林網(wǎng)。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 兴海县| 郁南县| 岳普湖县| 万源市| 镇雄县| 阜新市| 论坛| 锡林郭勒盟| 通州区| 兴化市| 林州市| 平利县| 彰化县| 固阳县| 乡宁县| 泰顺县| 淳安县| 定日县| 远安县| 芜湖市| 文水县| 盐津县| 杭州市| 凤山县| 久治县| 吉首市| 陵川县| 仪陇县| 云和县| 深水埗区| 金华市| 唐海县| 璧山县| 广灵县| 醴陵市| 梁河县| 杨浦区| 农安县| 叶城县| 石首市| 萨嘎县|