title: Android: multiple fragments within a constraint layout
body: <p>In advance, thank you for taking a few moments to read through this question and point out what is most likely an obvious mistake in my code. I've done some research and can't find a similar question- so here it is. </p>
  
  <p>I am trying to create an android screen that shows 3 fragments separated on the screen like this- (first fragment in upper left as a search fragment, second (beneath it as a recycler layout) and the third detail fragment which inflates once an object is clicked on from the recycler list. </p>
  
  <p>Page layout example:</p>
  
  <p><a href="https://i.stack.imgur.com/Imqlj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Imqlj.png" alt="page layout example"></a></p>
  
  <p>I've accomplished this using a linear layout with two fragment containers with layout_weights, so when the search button is clicked in the first fragment, the recycler list takes the spot of the search fragment, and once clicked on inflates the detail container on the right, but again ideally id like all three fragments to be on the screen at the same time. </p>
  
  <p>Here's the XML test layout that'd like to use:</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:layout_width="match_parent"
  android:layout_height="match_parent"&gt;
  
  &lt;fragment
      android:id="@+id/fragmentTest1"
      android:name="com.swimlabs.pcms.progressionapp.SearchFragment"
      android:layout_width="319dp"
      android:layout_height="179dp"
      android:layout_marginEnd="2dp"
      app:layout_constraintBottom_toTopOf="@+id/divider"
      app:layout_constraintEnd_toStartOf="@+id/divider2"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;View
      android:id="@+id/divider"
      android:layout_width="325dp"
      android:layout_height="14dp"
      android:layout_marginEnd="2dp"
      android:layout_marginTop="200dp"
      android:background="?android:attr/listDivider"
      app:layout_constraintEnd_toStartOf="@+id/divider2"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;View
      android:id="@+id/divider2"
      android:layout_width="14dp"
      android:layout_height="711dp"
      android:layout_marginEnd="938dp"
      android:background="?android:attr/listDivider"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toEndOf="@+id/fragmentTest1"
      app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;fragment
      android:id="@+id/fragmentTest2"
      android:name="com.swimlabs.pcms.progressionapp.SwimmerListFragment"
      android:layout_width="270dp"
      android:layout_height="424dp"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="2dp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toStartOf="@+id/divider2"
      app:layout_constraintStart_toStartOf="parent" /&gt;
  
  &lt;fragment
      android:id="@+id/fragment5"
      android:name="com.swimlabs.pcms.progressionapp.ProgressionFragment"
      android:layout_width="923dp"
      android:layout_height="640dp"
      android:layout_marginBottom="7dp"
      android:layout_marginEnd="9dp"
      android:layout_marginStart="8dp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toEndOf="@+id/divider2" /&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  </code></pre>
  
  <p>Here are code excerpts how I am dynamically creating the fragments. Here is my singleton fragment class. What's commented out here is my old code which worked for with the linear layout with 2 containers. </p>
  
  <pre><code>public abstract class SingleFragmentActivity extends AppCompatActivity {
  
  protected abstract Fragment createFragment();
  
  @LayoutRes
  protected int getLayoutResId() {
  //        return R.layout.master_coach;
      return R.layout.test;
  
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(getLayoutResId());
  
      FragmentManager fm = getSupportFragmentManager();
  //        Fragment fragment = fm.findFragmentById(R.id.fragment_container);
      Fragment fragment = fm.findFragmentById(R.id.fragmentTest1);
  
      if (fragment == null) {
          fragment = createFragment();
          fm.beginTransaction()
  //                   .add(R.id.fragment_container, fragment)
                  .add(R.id.fragmentTest1, fragment)
                  .commit();
      }
  
    }
  
  }
  </code></pre>
  
  <p>Here is the onClick method from within the search fragment. I've tried overriding the onCreateView method from the SwimmerListActivity, and also tried playing with the fragment manager, but none of this works. </p>
  
  <pre><code>mSearchButton.setOnClickListener(new View.OnClickListener () {
          @Override
          public void onClick(View v) {
  
  //                Fragment fragment = SwimmerListFragment.newInstance();
  //                FragmentManager fm = 
  //    getActivity().getSupportFragmentManager();
  //                fm.beginTransaction()
  //                        .add(R.id.fragmentTest2, fragment)
  //                        .commit();
              Intent intent = new Intent(getActivity(), 
  SwimmerListActivity.class);
              startActivity(intent);
  
          }
      });
  </code></pre>
  
  <p>I keep getting an error like this: </p>
  
  <blockquote>
    <p>08-13 19:04:59.291 21931-21931/com.swimlabs.pcms.progressionapp E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.swimlabs.pcms.progressionapp, PID: 21931
        <strong>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.swimlabs.pcms.progressionapp/com.swimlabs.pcms.progressionapp.CoachActivity}: android.view.InflateException: Binary XML file line #41: Binary XML file line #41: Error inflating class fragment</strong>
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
            at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)</p>
  </blockquote>
  
  <p>Where line 41 is the test.xml line where the second fragment begins. </p>
  
  <p>If you can't tell I'm very new to this but I appreciate any resources or even general advice from you guys that can point me in the right direction to fix this. I don't expect anyone here to write my code for me. Thanks, please let me know if I can include any other information.</p>