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();
}
}
});
}
}
i have created a login page for my app. while i am running in my emulator if the password and username matches it should go to next screen but while running this if the username and password is wrong the app is going to second page can anyone suggest
Replace this code with your code,this will work perfectly