title: How can I replace fragment inside a fragment?
body: <p>I have an Activity with a ViewPager, each page of the ViewPager has a Fragment.</p>
  
  <p>Inside my <code>Screen3Fragment</code> I have a LinearLayout (<code>lly_fragments</code>) where I am showing some other fragments. I start by showing the fragment <code>Screen3_1</code></p>
  
  <pre><code>public class Screen3Fragment extends Fragment {
  
      private FragmentManager manager;
      private FragmentTransaction transaction;
  
  
      public static Screen3Fragment newInstance() {
          final Screen3Fragment mf = new Screen3Fragment();
          return mf;
      }
  
      public Screen3Fragment() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          View v = inflater.inflate(R.layout.fragment_screen3, container, false);
          Screen3_1Fragment frag31 = new Screen3_1Fragment();
          manager = getChildFragmentManager();
          transaction = manager.beginTransaction();
          transaction.add(R.id.lly_fragments,frag31,"frag31");
          transaction.addToBackStack("frag31");
          transaction.commit();
          return v;
      }
  
  }
  </code></pre>
  
  <p>This works fine without problems. Problem comes when, from within <code>frag31</code> (which is inside Screen3Fragment), I want to call <code>fragt32</code>, for that I do the following.</p>
  
  <pre><code>public class Screen3_1Fragment extends Fragment {
  
      private ImageButton imgbt_timer;
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
  
          View v = inflater.inflate(R.layout.fragment_screen3_1,container,false);
          imgbt_timer = (ImageButton) v.findViewById(R.id.bT_scr31_timer);
          imgbt_timer.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  getChildFragmentManager().beginTransaction()
                                              .replace(R.id.lly_fragments, new Screen3_2Fragment(), "frag32")
                                              .commit();
              }
          });
  
  
          return v;
      }
  }
  </code></pre>
  
  <p>As I read in other answers, the line <code>transaction.replace</code>should do the trick and replace the existing <code>frag31</code> by the given <code>frag32</code> inside the same given container <code>lly_fragments</code>.</p>
  
  <p>However, I get <code>java.lang.IllegalArgumentException: No view found for id.....</code> I am not sure why.</p>