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