This my code about authentification, but I do not understand why when I run my code "else" display "Unexpected token".
username = (EditText) findViewById(R.id.editTextUsername_id);
motdepasse = (EditText) findViewById(R.id.editTextPassword_id);
signin = (Button) findViewById(R.id.btnSignIn_id);
signin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
if (username.getText().toString().equals("admin") && motdepasse.getText().toString().equals("admin"));
Intent intention = new Intent( Login.this, ATM.class);
startActivity(intention);
}
else {
Toast.makeText(Login.this, "Username or Password", Toast.LENGTH_LONG).show();
}
});
}
`
I am expectin to resolv my coding problem
It should be like- check if condition and onclick method.
username = (EditText) findViewById(R.id.editTextUsername_id);
motdepasse = (EditText) findViewById(R.id.editTextPassword_id);
signin = (Button) findViewById(R.id.btnSignIn_id);
signin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (username.getText().toString().equals("admin") && motdepasse.getText().toString().equals("admin")) {
startActivity( new Intent(Login.this, ATM.class));
} else {
Toast.makeText(Login.this, "Username or Password", Toast.LENGTH_LONG).show();
}
}
});
}