Android Note -5-edittext Password and checkbox two select one

Source: Internet
Author: User

EditText Password: plaintext and ciphertext

Ciphertext:

1  Public classMainactivityextendsActivity {2       3       PrivateEditText Password =NULL;4 @Override5       protected voidonCreate (Bundle savedinstancestate) {6           Super. OnCreate (savedinstancestate);7 Setcontentview (r.layout.activity_main);8           9           This. Password = (EditText)Super. Findviewbyid (r.id.pwdedittext);Ten          //set to Redaction OneMainactivity. This. Password.settransformationmethod (Passwordtransformationmethod.getinstance ()); A          -      } -   the @Override -       Public BooleanOncreateoptionsmenu (Menu menu) { -          //inflate the menu; This adds items to the action bar if it is present. - getmenuinflater (). Inflate (R.menu.main, menu); +          return true; -      } +}

Vmcontext Toggle (checkbox Toggle):

 Public classMainactivityextendsActivity {PrivateEditText Password =NULL; PrivateCheckBox show =NULL; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                Setcontentview (R.layout.activity_main);  This. Password = (EditText)Super. Findviewbyid (R.id.pwdedittext); Mainactivity. This. Password.settransformationmethod (Passwordtransformationmethod.getinstance ());  This. Show = (CheckBox)Super. Findviewbyid (R.id.display_checkbox);  This. Show.setonclicklistener (NewONCLICKLISTENERLMP ()); } @Override Public BooleanOncreateoptionsmenu (Menu menu) {//inflate the menu; This adds items to the action bar if it is present.getmenuinflater (). Inflate (R.menu.main, menu); return true; }     Public voidregister (view view) {Intent Intent=NewIntent (); Intent.setclass ( This, Registeractivity.class);  This. StartActivity (Intent); }    Private classOnclicklistenerlmpImplementsonclicklistener{@Override Public voidOnClick (View v) {//TODO auto-generated Method Stub            if(Mainactivity. This. show.ischecked ()) {                //set to clear text displayMainactivity. This. Password.settransformationmethod (Hidereturnstransformationmethod.getinstance ()); }            Else{                //set to ciphertext displayMainactivity. This. Password.settransformationmethod (Passwordtransformationmethod.getinstance ()); }        }    }}

CheckBox two Select one

 Public classRegisteractivityextendsActivity {PrivateCheckBox choose1 =NULL; PrivateCheckBox Choose2 =NULL; @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);  Setcontentview (R.layout.activity_register);  This. Choose1 = (CheckBox)Super. Findviewbyid (R.id.sex_checkbox1);  This. Choose2 = (CheckBox)Super. Findviewbyid (R.id.sex_checkbox2); } @Override Public BooleanOncreateoptionsmenu (Menu menu) {//inflate the menu; This adds items to the action bar if it is present.      getmenuinflater (). Inflate (R.menu.register, menu); return true; } Public voidChoose (View view) {if(Registeractivity. This. choose1.ischecked ()) {choose2.setchecked (false); }Else{choose1.setchecked (false); }}}

Android Note -5-edittext Password and checkbox two select one

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.