2017年3月8日 星期三

Login Screen

Login Screen


Login Screen:登入介面。


          在java檔案中,使用者名稱和密碼需要用getText()和 toString()的方法,還要加上用來比對使用者名稱和密碼是否相符的 equals()方法。


   下面這段程式是在onClick 方法 底下:

public void login(View view){
   if(username.getText().toString().equals("admin") && password.getText().toString().equals("admin")){
   
   //correcct password
   }else{
   //wrong password
}

         第二件事,要做一個安全機制,避免企圖多餘的次數。每次輸入錯誤,就會遞減。當count=0時,禁止登入。


  int counter = 3;
     counter--;

if(counter==0){
   //disble the button, close the application e.t.c
}


參考文獻

Android Login Example
https://examples.javacodegeeks.com/android/android-login-example/

Android Material Design Login Form XML UI Design


Android Login and Registration with PHP, MySQL and SQLite



沒有留言:

張貼留言