title: Cannot resolve method startactivity()
body: <p>I'm new to the android development and having a bit of a problem changing activities. I am trying to change activities from within a method but I am getting the error cannot resolve method startActivity and on the parameter end the error Cannot resolve constructor 'Intent (...)'. I found a question here with the same sort of problem and tried to implement their replies into my program but no joy.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>public void onButtonClick(View v) {
  
      if (v.getId() == R.id.Blogin) {
          EditText a = (EditText)findViewById(R.id.TFusername);
          String str = a.getText().toString();
          Intent i = new Intent(MainActivity.this, Display.class);
          i.putExtra("Username", str);
          startActivity(i);
      }
  
      if (v.getId() == R.id.Bsignup) {
          Intent i = new Intent(MainActivity.this, SignUp.class);
          startActivity(i);
      }
  }
  </code></pre>
  
  <p>Complete code:</p>
  
  <pre><code>package in.chaitu.example.loginandregister;
  
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.content.Intent;
  import android.widget.EditText;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
      public void onButtonClick(View v) {
  
          if (v.getId() == R.id.Blogin) {
              EditText a = (EditText)findViewById(R.id.TFusername);
              String str = a.getText().toString();
              Intent i = new Intent(MainActivity.this, Display.class);
              i.putExtra("Username", str);
              startActivity(i);
          }
  
          if (v.getId() == R.id.Bsignup) {
              Intent i = new Intent(MainActivity.this, SignUp.class);
              startActivity(i);
          }
      }
  }
  </code></pre>