我在输入用户名和密码(如果两者相等)时创建了一个登录页面,它用于登录,但用户名和密码留空,当我点击模拟器上的登录按钮时,它显示登录成功它不应该登录时用户名和密码留空
@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) {
if((txtUserName.getText().toString()).equals(txtPassword.getText().toString())){
Intent myIntent = new Intent(v.getContext(), SaveData.class);
startActivityForResult(myIntent, 1);
Toast.makeText(LoginappActivity.this, "Login Successful",Toast.LENGTH_LONG).show();
} else{
Toast.makeText(LoginappActivity.this, "Invalid Login",Toast.LENGTH_LONG).show();
}
}
});
}
}