title: Error message "No view found" when creating fragment in Android
body: <p>I'm starting to learn Android and am having a problem when creating fragments. I've tried creating a fragment in code in just about every way every tutorial specifies but every time I do the program immediately crashes and I get a log error "no view found for [id of fragment for container]". </p>
  
  <p>The activity I create the fragment from is:</p>
  
  <pre><code>public class MainActivity extends FragmentActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      FragmentManager fm = getSupportFragmentManager();
      FragmentTransaction ft = fm.beginTransaction();
  
      FragmentTestActivity activity = new FragmentTestActivity();
      ft.add(R.id.fragment_container, activity);
      ft.commit();
  }
  
  
  }
  </code></pre>
  
  <p>The fragment itself if</p>
  
  <pre><code>public class FragmentTestActivity extends Fragment {
  
  public View onCreateView(LayoutInflater inflater, ViewGroup parent,
                           Bundle savedInstanceState) {
      View vw = inflater.inflate(R.layout.fragment, parent, false);
      return vw;
  }
  }
  </code></pre>
  
  <p>And the layout of the fragment is</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/fragment_container" &gt;
  
  
  &lt;/FrameLayout&gt;  
  </code></pre>
  
  <p>It doesn't do anything useful at the moment, I just want to see if I can make a fragment before moving on to do anything useful, but every time I try the program crashes.</p>