Business Flowchart:
Development steps:
- Get user-entered account number and password
- Using if logical statements for business logic judgment
- Give the user the appropriate hints based on the results of the judgment
Code:
1 Public classLoginactivityextendsappcompatactivity {2 3 4 PrivateButton Btnlogin;5 PrivateEditText Txtaccount,txtpassword;6 7 @Override8 protected voidonCreate (Bundle savedinstancestate) {9 Ten Super. OnCreate (savedinstancestate); One Setcontentview (r.layout.activity_login); A - This. Btnlogin = (Button) This. Findviewbyid (R.id.btnlogin); - This. Txtaccount = (EditText) This. Findviewbyid (R.id.txtaccount);//get user-entered account number the This. Txtpassword = (EditText) This. Findviewbyid (R.id.txtpassword);//get the password entered by the user - - This. Btnlogin.setonclicklistener (NewViewocl ()); - + } - + A Private classViewoclImplementsview.onclicklistener{ at @Override - Public voidOnClick (View v) { - Switch(V.getid ()) { - CaseR.id.btnlogin: -String account=Txtaccount.gettext (). toString (). Trim (); -String password=Txtpassword.gettext (). toString (). Trim (); in BooleanLogin_flag =false; - to if("admin". Equals (account) && "123". Equals (password)) {//using if logical statements for business logic judgment +login_flag=true; - } the *String message = Login_flag? "Welcome login," +account: "Incorrect account or password";//give the user the appropriate hints based on the results of the judgment $ Toast.maketext (Getapplicationcontext (), Message,toast.length_long). Show ();Panax Notoginseng Break; - CaseR.id.btnregister: the Break; + default: Break; A } the } + } -}
Loginactivity.java
Run:
Click how events are handled and the creation of the registration Form (ii) Implementation of login business logic