title: How can I make a password to open up a page using a button an edit Text box and if/else statement (Android)
body: <p>I am trying to make a password to get into an a page in Android. I am using a String password to store a password. ie String password = bob. I am using an EditText box to enter a word and currently I am using an if else statement to check if the password and the EditText input are correct. To  carry out this function I am using a button to make this check. </p>
  
  <p>Here is the code I have made so far</p>
  
  <pre><code>package com.example.explicitintent;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  public class MainActivity extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
                  super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      //////////////////////////////////////////////////////////////
  
      Button invokingButtons = (Button) findViewById(R.id.button1);
      invokingButtons.setOnClickListener(new OnClickListener() {
  
                  @Override
      public void onClick(View v) {
          // TODO Auto-generated method stub
      String password = "bob";
      EditText myEditText = (EditText) findViewById(R.id.EditText);
      if(myEditText.equals(password)){
      Intent explicitIntent = new Intent(MainActivity.this,NextActivity.class);
      startActivity(explicitIntent);
  
  }else{
  
    Toast.makeText(getApplicationContext(),
   "this is my Toast message!!! =)", Toast.LENGTH_LONG).show  ();
  
                  }
          }
          });
  
  
              };
          };  
  </code></pre>