Website in order to prevent malicious access to verify the message, verify the mailbox, will be clicked on the button to get the verification code to do a countdown effect, how to achieve this effect, the specific content as follows
Effect Chart:
Code:
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;
/** * Registration function * 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, "account Registration", true);
Gets the authentication code--start BTN_YZM = (Button) Findviewbyid (R.ID.BTN_YZM); Btn_yzm.setonclicklistener (New View.onclicklistener () {@Override public void OnClick (View v) {Countdownbuttonhelpe
R helper = new Countdownbuttonhelper (Btn_yzm, "Countdown", 60, 1); Helper.setonfinishlistener (nEW Countdownbuttonhelper.onfinishlistener () {@Override public void finish () {//Toast.maketext (registeractivity
. This, "Countdown is Over", Toast.length_short. Show ();
Btn_yzm.settext ("Get Again");
}
});
Helper.start (); }
});
Get Authentication Code--end}}
Layout file:
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:hi nt= "@string/edt_phone_tips" android:maxlength= "android:layout_gravity=" center_vertical "android:singleline=" True "android:textsize=" 16sp "/> <view android:layout_width=" 2px "android:layout_height=" 50DP "Android:bac kground= "@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:layou T_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 "a Ndroid: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= "35d P "android:layout_torightof=" @id/tv_phone "android:background=" @null "android:hint=" @string/edt_yzm_tips "Android: Maxlength= "android:layout_gravity=" "Center_vertical" android:singleline= "true" android:textsize= "16sp"/> &L t;/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:o rientation= "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/e T_password "android:layout_width=" 190DP "android:layout_height=" 35DP "android:layout_torightof=" @id/tv_phone "Andr Oid:background= "@null" android:hint= "@string/edt_passWord_text "android:maxlength=" android:layout_gravity= "center_vertical" android:singleline= "true" Android:textS Ize= "16sp"/> </LinearLayout> <view android:id= "@+id/view_line2" android:layout_width= "Match_parent" an droid: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>
The above is the entire content of this article, I hope to give you a reference, but also hope that we support the cloud-dwelling community.