What's new
DroidForums.net | Android Forum & News

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Help with my code...

smithmanny

New Member
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();

}

}
});


}


}
 
Back
Top