EditText txtUserName;
EditText txtPassword;
Button btnLogin;
Button btnCancel;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
txtUserName=(EditText)this.findViewById(R.id.txtUname);
txtPassword=(EditText)this.findViewById(R.id.txtPwd);
btnLogin=(Button)this.findViewById(R.id.btnLogin);
btnLogin.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent myIntent = new Intent(v.getContext(), AddName.class);
startActivityForResult(myIntent, 0);
if((txtUserName.getText().toString()).equals(txtPassword.getText().toString())){
Toast.makeText(LoginappActivity.this, "Login Successful",Toast.LENGTH_LONG).show();
} else{
Toast.makeText(LoginappActivity.this, "Invalid Login",Toast.LENGTH_LONG).show();
}
}
});
}
}
我爲我的應用創建了一個登錄頁面。而我在我的模擬器中運行,如果用戶名和密碼相匹配,應該進入下一個畫面,但在運行此,如果用戶名和密碼是錯誤的應用程序將會第二頁任何人都可以提出在android中創建登錄頁面