title: Start fragment activity
body: <p>I have an application with many fragments, and am trying to go from one fragment to another when a button is clicked.</p>
  
  <p>The part I'm having trouble with is <code>startActivity(new Intent(HomeFragment.this, FindPeopleFragment.class));</code></p>
  
  <pre><code>package info.androidhive.slidingmenu;
  
  import info.androidhive.slidingmenu.HomeFragment;
  import android.app.Fragment;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageButton;
  import android.widget.Toast;
  
  public class HomeFragment extends Fragment {
  
  public HomeFragment() {
  }
  
  ImageButton bSearchByLocation, bSearchByNumber;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      super.onCreateView(inflater, container, savedInstanceState);
      View InputFragmentView = inflater.inflate(R.layout.fragment_home,
              container, false);
  
      bSearchByNumber = ((ImageButton) InputFragmentView
              .findViewById(R.id.bSearchByLocation));
      bSearchByLocation = ((ImageButton) InputFragmentView
              .findViewById(R.id.bSearchByNumber));
  
      bSearchByLocation.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              if (v.getId() == R.id.bSearchByNumber) {
                  Toast.makeText(getActivity(), "1", Toast.LENGTH_SHORT)
                          .show();
                   startActivity(new Intent(HomeFragment.this, FindPeopleFragment.class));
              }
          }
      });
      bSearchByNumber.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              if (v.getId() == R.id.bSearchByLocation) {
                  Toast.makeText(getActivity(), "2", Toast.LENGTH_SHORT)
                          .show();
              }
          }
      });
      return InputFragmentView;
  }
  }
  </code></pre>
  
  <p>after i do the solution the code look like this :</p>
  
  <pre><code>package info.androidhive.slidingmenu;
  
  import info.androidhive.slidingmenu.HomeFragment;
  import android.app.Fragment;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.Toast;
  
  public class HomeFragment extends Fragment {
  
  public HomeFragment() {
  }
  
  ImageButton bSearchByLocation, bSearchByNumber;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
  
      super.onCreateView(inflater, container, savedInstanceState);
      View InputFragmentView = inflater.inflate(R.layout.fragment_home,
              container, false);
  
      bSearchByNumber = ((ImageButton) InputFragmentView
              .findViewById(R.id.bSearchByLocation));
      bSearchByLocation = ((ImageButton) InputFragmentView
              .findViewById(R.id.bSearchByNumber));
  
      bSearchByLocation.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              if (v.getId() == R.id.bSearchByNumber) {
                  Toast.makeText(getActivity(), "1", Toast.LENGTH_SHORT)
                          .show();
                  startActivity(new Intent(getActivity(), FindPeopleFragment.class));
              }
          }
      });
      bSearchByNumber.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              if (v.getId() == R.id.bSearchByLocation) {
                  Toast.makeText(getActivity(), "2", Toast.LENGTH_SHORT)
                          .show();
              }
          }
      });
      return InputFragmentView;
  }
  }
  </code></pre>
  
  <p>but when i Run it , the application crash and closed.
  this is my androidmanifest code :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="info.androidhive.slidingmenu"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="11"
      android:targetSdkVersion="17" /&gt;
  
  &lt;application
  android:allowBackup="true"
  android:icon="@drawable/ic_launcher"
  android:label="@string/app_name"
  android:theme="@style/AppTheme" &gt;
  &lt;activity
      android:name="info.androidhive.slidingmenu.MainActivity"
      android:label="@string/app_name" &gt;
      &lt;intent-filter&gt;
          &lt;action android:name="android.intent.action.MAIN" /&gt;
  
          &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
      &lt;/intent-filter&gt;
  &lt;/activity&gt;
  &lt;activity android:name="info.androidhive.slidingmenu.FindPeopleFragment"&gt;&lt;/activity&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>and this is my logchat:
  <img src="https://i.stack.imgur.com/NlDD3.png" alt="enter image description here"></p>
  
  <p>by the way .... i use this surce code and work on it :
  <a href="http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer" rel="nofollow noreferrer">http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer</a></p>