Help with my code...

smithmanny

New Member
Joined
Jul 28, 2010
Messages
7
Reaction score
0
Location
Atlanta, GA
I am trying to setup a login screen with toast notification, but every time I type in the right info I set up for my toast notification it only display the "else" statement instead of the "if".
public class LoginActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.login_layout);


/**
* Creating all buttons instances
* */
// Login button
Button bLogin = (Button) findViewById(R.id.bLogin);
// EditText Email
final EditText etEmail = (EditText) findViewById(R.id.etEmail);
// EditText Password
final EditText etPassword = (EditText) findViewById(R.id.etPassword);


/**
* Handling all button click events
* */
bLogin.setOnClickListener(new View.OnClickListener() {

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(etEmail.equals("admin") && etPassword.equals("admin")){
Context context = getApplicationContext();
CharSequence text = "Login Successful!";
int duration = Toast.LENGTH_SHORT;


Toast toast = Toast.makeText(context, text, duration);
toast.show();
}else{
Context context = getApplicationContext();
CharSequence text = "Login failed. Username and/or password doesn't match.";
int duration = Toast.LENGTH_SHORT;


Toast toast = Toast.makeText(context, text, duration);
toast.show();

}

}
});


}


}
 
Top