Android One registration page and verification code implementation

Source: Internet
Author: User

First on:



The verification code is implemented using PHP's return ImageView, with the following XML:

<?xml version= "1.0" encoding= "Utf-8"? ><scrollviewxmlns:android= "http://schemas.android.com/apk/res/ Android "Android:layout_width=" Fill_parent "android:layout_height=" fill_parent "android:background=" #f3f3f9 "> <linearlayoutandroid:orientation= "vertical" android:layout_width= "fill_parent" android:layout_height= "Fill_ Parent "><relativelayoutandroid:layout_width=" fill_parent "android:layout_height=" Wrap_content "Android: Layout_margin= "10DP" ><textviewandroid:id= "@+id/tvusrname" android:text= "User name" Android:layout_width= "Wrap_ Content "android:layout_height=" 48DP "android:gravity=" center_vertical "android:textcolor=" @android: Color/black "/ ><edittextandroid:id= "@+id/etusrname" android:layout_width= "fill_parent" android:layout_height= "48DP" android:layout_marginleft= "5DP" android:textsize= "16sp" android:layout_torightof= "@id/tvusrname" Android: Textcolor= "@android: Color/black" android:selectallonfocus= "true"/></relativelayout>< Relativelayoutandroid:layout_width= "Fill_pareNT "android:layout_height=" Wrap_content "android:layout_margin=" 10DP "><textviewandroid:id=" @+id/tvPassword "android:text=" password "android:layout_width=" wrap_content "android:layout_height=" 48DP "android:gravity=" Center_ Vertical "android:textcolor=" @android: Color/black "/><edittextandroid:id=" @+id/etpassword "Android:layout_ Width= "Fill_parent" android:layout_height= "48DP" android:layout_marginleft= "5DP" android:layout_torightof= "@id/ Tvpassword "android:textsize=" 16sp "android:password=" true "android:textcolor=" @android: Color/black "/></ Relativelayout><relativelayoutandroid:layout_width= "Fill_parent" android:layout_height= "Wrap_content" Android:layout_margin= "10DP" ><textviewandroid:id= "@+id/tvpasswordconfirm" android:text= "Password Confirm" Android: Layout_width= "Wrap_content" android:layout_height= "48DP" android:gravity= "center_vertical" android:textColor= "@ Android:color/black "/><edittextandroid:id=" @+id/etpasswordconfirm "android:layout_width=" Fill_parent " android:layout_height= "48DP" AndroiD:textsize= "16sp" android:layout_torightof= "@id/tvpasswordconfirm" android:password= "true" android:textcolor= "@ Android:color/black "/></relativelayout><relativelayoutandroid:layout_width=" Fill_parent "Android: layout_height= "Wrap_content" android:layout_margin= "10DP" ><textviewandroid:id= "@+id/tvNickName" Android: text= "nickname" Android:layout_width= "Wrap_content" android:layout_height= "48DP" android:gravity= "center_vertical "Android:textcolor=" @android: Color/black "/><edittextandroid:id=" @+id/etnickname "android:layout_width=" Fill_parent "android:layout_height=" 48DP "android:layout_marginleft=" 5DP "android:maxlines=" 2 "android:textSize=" 16sp "android:layout_torightof=" @id/tvnickname "android:textcolor=" @android: Color/black "/></relativelayout ><relativelayoutandroid:layout_width= "Fill_parent" android:layout_height= "Wrap_content" Android:layout_ Margin= "10DP" ><textview android:id= "@+id/tvgender" android:text= "Sex" android:textcolor= "#484848" Andro Id:layouT_centervertical= "true" android:textsize= "16DP" android:layout_width= "Wrap_content" android:layout_he        ight= "Wrap_content"/> <radiogroup android:id= "@+id/rgsex" android:layout_width= "Fill_parent" android:layout_height= "Wrap_content" android:layout_marginleft= "5dip" android:layout_torightof= "@id/tvgende            R "android:layout_marginbottom=" 10DP "android:orientation=" Horizontal "> <radiobutton Android:id= "@+id/rbrgmale" android:layout_width= "wrap_content" android:layout_height= "wrap_content            "Android:textcolor=" @android: Color/black "android:text=" male "/> <radiobutton Android:id= "@+id/rbrgfemale" android:layout_width= "wrap_content" android:layout_height= "Wrap_cont Ent "android:textcolor=" @android: Color/black "android:text=" female "android:layout_margin left= "50DP"/> </radiogroup> </RelativeLayout> <relativelayout android:layout_width= "Fill_parent" Android:lay              out_height= "Wrap_content" > <imageview android:id= "@+id/ivauthpic" android:src= "@drawable/image1" android:layout_marginleft= "40DP" android:layout_alignparentleft= "true" android:layout_centervertical= "true" an Droid:layout_width= "100DP" android:layout_height= "30DP"/> <button android:id= "@+id/btnchangeaauthpic" an Droid:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:layout_alignparentright= "true" and    Roid:layout_gravity= "Right" android:layout_marginright= "10DP" android:text= "not clear" android:textcolor= "#000"/> </RelativeLayout> <edittextandroid:id= "@+id/etauthcode" android:layout_width= "Fill_parent" Android: layout_height= "48DP" android:layout_margin= "10DP" android:inputtype= "Textvisiblepassword" android:textcolor= "@ Android:color/black "/> <button AndroidOid:id= "@+id/btnok" android:textsize= "15sp" android:textcolor= "#fff" android:text= "Confirm" android:background= "@draw Able/button_item_selector "android:layout_gravity=" center "android:layout_height=" Wrap_content "Android:layout_ Width= "Wrap_content"/></linearlayout></scrollview>

Code:

int[] array = new Int[]{r.drawable.image1,r.drawable.image2,r.drawable.image3}; Boolean ismale; @Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.registerquick); RadioButton Rbmale = (RadioButton) Findviewbyid (R.id.rbrgmale); RadioButton Rbfmale = (RadioButton) Findviewbyid (R.id.rbrgfemale); Rbmale.setonclicklistener (new Onclicklistener () { public void OnClick (View v) {//TODO auto-generated method Stubismale = True;}});  Rbfmale.setonclicklistener (New Onclicklistener () {public void OnClick (View v) {//TODO auto-generated Method Stubismale = false;}}); Final ImageView ivauthpic = (ImageView) Findviewbyid (r.id.ivauthpic); Button Btnchangeaauthpic = (button) Findviewbyid (r.id.btnchangeaauthpic); Btnchangeaauthpic.setonclicklistener (new View.onclicklistener () {@Overridepublic void OnClick (View v) {Random d = new Random (); int k = Math.Abs (D.nextint ())% 3;iv Authpic.setimageresource (Array[k]);}); 



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.