DroidForums.net is the original Verizon Android Forum! Registered Users do not see these ads. Please Register - It's Free!
Results 1 to 1 of 1

Thread: Help with my code...

  1. Junior Droid
    smithmanny's Avatar
    Member #
    95706
    Join Date
    Jul 2010
    Location
    Atlanta, GA
    Posts
    8
    Twitter
    smithmanny
    Phone
    Thunderbolt
    #1

    Help with my code...

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

    }

    }
    });


    }


    }
  2. Sponsor
    DF Advertising
    Join Date
    Nov 2008
    Location
    DroidForums.net
     
     
     
     

Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Similar Threads

  1. QR Code Tip
    By mivok in forum Android General Discussions
    Replies: 5
    Last Post: 10-15-2012, 09:12 AM
  2. No PKU code??!
    By Z06_Mir in forum HTC ThunderBolt
    Replies: 2
    Last Post: 10-13-2011, 10:08 AM
  3. Code corrupt
    By bobAbooey in forum Droid X Tech Support
    Replies: 1
    Last Post: 05-09-2011, 01:19 PM
  4. qr code scanner
    By journeygirl in forum Android General Discussions
    Replies: 3
    Last Post: 07-09-2010, 05:07 AM
Find us on Google+