Home > Mobile >  Android login screen
Android login screen

Time:11-02

Write an android login page complete code (including resources, interface (design), event), requirements: click "login" button, if the user name and password is "admin" and "123456" respectively, jump to the welcome screen; When you click "cancel" function of empty

CodePudding user response:

I want to know how to judge the user name and password are admin and then jump to the welcome page 123456

CodePudding user response:

Object the findviewbyid () to obtain the input box, and then get the value judgment, if want to experience the login validation process, can be directly the local write dead judgment, not a post request to the background, or your local build a database used for calibration

CodePudding user response:

 
The EditText edAccount=the findViewById (R.i d.e d_account);
The EditText edPwd=the findViewById (R.i d.e d_pwd);

//click login button
String account=edAccount. GetText (). The toString (). The trim ();
String PWD=edPwd. GetText (). The toString (). The trim ();
If ((" ademin ".) the equals (account) & amp; & (" 123456 "). The equals (PWD)) {
Toast. MakeText (MainActivity. This, "login succeeds", Toast. LENGTH_SHORT), show ();
} else {
Toast. MakeText (MainActivity. This "user or password password is not correct," Toast. LENGTH_SHORT), show ();
}

CodePudding user response:



<script>
The import axios from 'axios'
Export the default {
Data () {
Return {
User: {

},

}
},
Mounted () {

},
Methods: {
Loginuser () {
Var url=` ` http://localhost:8080/user
Axios. Post (url, enclosing the user)
. Then ((response)=& gt; {
If (the response data. Code==1) {

Alert (response) data) message)
This $router. Push ('/newsList ')
} else {
Alert (response) data) message)
}
})
The catch ((error)=& gt; {
Alert (" fail ")
})
},
(aa) {
Var url=` ` http://localhost:8080/user
Axios. Post (url, enclosing the user)
. Then ((response)=& gt; {
If (the response data. Code==1) {
If (this. User username! .=the response data. The data. The username) {
Alert (" the user name does not exist ")
}
} else {
Alert (" the user name does not exist ")
}
})
The catch ((error)=& gt; {
Alert (" fail ")
})

}

},
}
</script>

CodePudding user response:

the above code directly to knock up,
  • Related