title: How do I redirect a Fragment to new Fragment?
body: <p>I'm fairly new to Android programming and I just want to know how could I redirect a Fragment to a new one. Here is my code:</p>
  
  <pre><code>package com.example.samsung.drawer;
  import android.support.v4.app.Fragment;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.AdapterView;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;
  
  public class First_frag_o extends Fragment {
  
  final String[] items = new String[]{"Natural Hazards", "Biological Hazards", "Chemical Hazards"
          };
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
  
      View view = inflater.inflate(R.layout.first0, container, false);
  
      ListView list = (ListView) view.findViewById(R.id.first123);
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getActivity(), android.R.layout.simple_list_item_1, items);
      list.setAdapter(adapter);
  
      list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                                  long arg3) {
              @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                                  long arg3) {
  
              Fragment myFragment = null;
              switch (arg2){
                  case 0:
                      myFragment = new NaturalHazards();
                      break;
                  case 1:
                      myFragment = new BiologicalHazards();
                      break;
                  case 2:
                      myFragment = new ChemicalHazards();
                      break;
  
              }
              // update the main content by replacing fragments
              FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
              fragmentManager.beginTransaction()
                      .replace(R.id.container1, myFragment)
                      .commit();
          }
      });
      return view;
  }
  }
  </code></pre>
  
  <p>first0.xml</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout   xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"         android:id="@+id/drawer_layout"
      android:layout_width="match_parent" android:layout_height="match_parent"
      tools:context=".MainActivity"&gt;
      &lt;FrameLayout android:id="@+id/container1"     android:layout_width="match_parent"
           android:layout_height="match_parent" android:background="#ff7f7f"&gt;
  &lt;ListView
    android:id="@+id/first123"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
  
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:choiceMode="singleChoice"
    android:descendantFocusability="blocksDescendants"    &gt;
  
  &lt;/ListView&gt;
      &lt;/FrameLayout&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>BiologicalHazards.Java:</p>
  
  <pre><code>import android.os.Bundle;
  import android.support.annotation.Nullable;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  
  public class BiologicalHazards extends Fragment {
  
   View myView;
   @Nullable
   @Override
   public View onCreateView(LayoutInflater inflater, ViewGroup container,   Bundle savedInstanceState) {
      myView = inflater.inflate(R.layout.haz,container,false);
  
       return myView;
   }
  }
  </code></pre>
  
  <p>For example, I want to go to the "Biological Hazards" fragment when I click on the list. How do I do it? Could anyone please show me how?</p>
  
  <p>Logcat:</p>
  
  <pre><code>08-30 19:46:57.633  31775-31775/com.example.samsung.drawer E/AndroidRuntime﹕      FATAL EXCEPTION: main
      Process: com.example.samsung.drawer, PID: 31775
      java.lang.IllegalArgumentException: No view found for id 0x7f0d006e (com.example.samsung.drawer:id/haztext) for fragment BiologicalHazards{21ddec38 #2 id=0x7f0d006e}
          at     android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
          at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
          at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
          at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
          at android.os.Handler.handleCallback(Handler.java:733)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:149)
          at android.app.ActivityThread.main(ActivityThread.java:5257)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>