Trim those edittexts and use userName.equals(userName1) for Strings!

On Sun, Feb 3, 2013 at 10:20 PM, <broc.hask...@us.army.mil> wrote:

> I am trying to create a login screen for your basic hello world program. I
> do not need a database for this so I hard coded the username and password
> directly into the code. The problem I am having is when I enter the correct
> username and password, I get my error message stating that either one is
> wrong. Here is the code I have, any help would be greatly appreciated.
>
>     public void welcomeScreen(View view){
>         String userName1 = "student";
>         String password1 = "school";
>         Intent intent = new Intent(this, WelcomeScreen.class);
>         EditText editText1 = (EditText) findViewById(R.id.editText1);
>         String userName = editText1.getText().toString();
>
>         EditText editText2 = (EditText) findViewById(R.id.editText2);
>         String password = editText2.getText().toString();
>
>         if(userName != userName1 || password != password1){
>             Context context = getApplicationContext();
>             CharSequence text = "Incorrect Username or Password!";
>             int duration = Toast.LENGTH_SHORT;
>
>             Toast toast = Toast.makeText(context, text, duration);
>             toast.show();
>         }
>
>         else startActivity(intent);
>     }
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Android Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to android-developers+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to