title: Trying to open a activity from a fragment tab with 4 buttons in it
body: <p>I am building an app in which I have 3 fragment tabs. In the first tab I have 4 buttons, which will open 4 different activities, but when I try to launch a new activity on button's <code>onClick</code> my app crashes. I will post my code here for first fragment tab which has 4 buttons in it. </p>
  
  <pre><code>import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.Toast;
  import android.app.Fragment;
  import android.content.Intent;
  
  
  public class Tab1 extends Fragment {
      Button btn1, btn2, btn3, btn4;
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.clienttab1, container, false);
          btn1 = (Button)rootView.findViewById(R.id.button1);
          btn2 = (Button)rootView.findViewById(R.id.button2);
          btn3 = (Button)rootView.findViewById(R.id.button3);
          btn4 = (Button)rootView.findViewById(R.id.button4);
          addListenerOnButton();
          return rootView;
      }
      public void addListenerOnButton() {
  
          btn1.setOnClickListener(new OnClickListener() {
          @Override
              public void onClick(View view) {
                  Intent intent = new Intent(getActivity(), Activity1.class);
                  startActivity(intent);
                  }
          });
          btn2.setOnClickListener(new OnClickListener() {
          @Override
              public void onClick(View view) {
                  Intent intent = new Intent(getActivity(), Activity2.class);
                  startActivity(intent);
              }
          });
          btn3.setOnClickListener(new OnClickListener() {
          @Override
              public void onClick(View view) {
                  Intent intent = new Intent(getActivity(), Activity3.class);
                  startActivity(intent);
              }
          });
          btn4.setOnClickListener(new OnClickListener() {
          @Override
              public void onClick(View view) {
                  Intent intent = new Intent(getActivity(), Activity4.class);
                  startActivity(intent);
              }
          });
  
      }
  
  } 
  </code></pre>