Paul-Peter Tournaris wrote:

> Trim those edittexts [sic] and use userName.equals(userName1) for Strings!
>
 
OP: This is fundamental Java, not specifically Android.

 <[email protected] <javascript:>> 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){
>>
>
Learn the difference between == / != and equals() / ! equals().

The Java tutorials might help with this.
 

>             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);
>>     }
>>
>> -- 
Lew
 

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to