title: How to open a new activity on click of textview in android?
body: <p>I am new to android programming world, I have designed as a layout with username, password AS edittext control and "forgot password" as textview control, on click/tap of "forgot password", I want to open a new activity. </p>
  
  <p>This is what I am trying, looking forward for your help.
  My Application's xml and java code is mentioned below.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:app="http://schemas.android.com/apk/res-auto"
          xmlns:tools="http://schemas.android.com/tools"
          android:id="@+id/relativeLayout"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:background="@android:color/holo_blue_light"&gt;
  
          &lt;TextView
              android:id="@+id/txtVwAccountLogin"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginTop="8dp"
              android:text="Account Login"
              android:textColor="@android:color/background_light"
              android:textSize="24sp"
              android:textStyle="bold"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
              app:layout_constraintVertical_bias="0.057" /&gt;
  
          &lt;EditText
              android:id="@+id/eTxtUserName"
              android:layout_width="288dp"
              android:layout_height="48dp"
              android:background="@android:color/background_light"
              android:ems="10"
              android:hint=" Username"
              android:inputType="textPersonName"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintHorizontal_bias="0.593"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
              app:layout_constraintVertical_bias="0.406" /&gt;
  
          &lt;EditText
              android:id="@+id/eTxtPassword"
              android:layout_width="290dp"
              android:layout_height="45dp"
              android:background="@android:color/background_light"
              android:ems="10"
              android:hint=" Password"
              android:inputType="textPassword"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintHorizontal_bias="0.606"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
              app:layout_constraintVertical_bias="0.535" /&gt;
  
          &lt;TextView
              android:id="@+id/txtVwForgetPassword"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Forget Password ?"
              android:textColor="@android:color/background_light"
              android:textSize="14sp"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintHorizontal_bias="0.854"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
              app:layout_constraintVertical_bias="0.632" /&gt;
  
          &lt;Button
              android:id="@+id/btnLogin"
              android:layout_width="128dp"
              android:layout_height="wrap_content"
              android:text="Login"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
              app:layout_constraintVertical_bias="0.779" /&gt;
  
          &lt;Button
              android:id="@+id/btnRegister"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginBottom="8dp"
              android:layout_marginEnd="8dp"
              android:layout_marginStart="16dp"
              android:layout_marginTop="8dp"
              android:background="@android:color/holo_blue_light"
              android:text="Register"
              android:textColor="@android:color/background_light"
              app:layout_constraintBottom_toBottomOf="parent"
              app:layout_constraintEnd_toEndOf="parent"
              app:layout_constraintHorizontal_bias="0.15"
              app:layout_constraintStart_toStartOf="parent"
              app:layout_constraintTop_toTopOf="parent"
              app:layout_constraintVertical_bias="0.662" /&gt;
      &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p><strong>Login.java</strong></p>
  
  <pre><code>    public class Login extends AppCompatActivity {
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.login);
  
              final TextView tvForgotPwd = (TextView) findViewById(R.id.txtVwForgetPassword);
  
              tvForgotPwd.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View view) {
                      Toast.makeText(Login.this, "you clicked me", Toast.LENGTH_SHORT).show();
                      Intent myIntent = new Intent(view.getContext(),PatientSearch.class);
                      startActivityForResult(myIntent, 0);
                  }
              });
              final Button btnRegister = (Button) findViewById(R.id.btnRegister);
  
              btnRegister.setOnClickListener(new View.OnClickListener() {
  
                  @Override
                  public void onClick(View view) {
                      Intent myIntent = new Intent(view.getContext(),MainActivity.class);
                      startActivityForResult(myIntent,0);
                  }
              });
  </code></pre>