title: No view found for id ... for fragment PlaceholderFragment
body: <p>I have a simple app (based on <a href="http://developer.android.com/training/basics/firstapp/starting-activity.html" rel="nofollow">the Android First App sample</a>); the only thing it does is show one EditText and a button. The button creates another activity, and show the EditText message ... simple! ... But when running on the emulator, the app closes when I click on the button and i get this error:</p>
  
  <blockquote>
    <p>"No view found for id 0x7f05003c (com.example.testapp:id/container) for fragment PlaceholderFragment{4173ead8 #0 id=0x7f05003c}"</p>
  </blockquote>
  
  <p><strong>MainActivity.java</strong></p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
  public final static String EXTRA_MESSAGE = "com.example.testapp.MESSAGE";
  
  public void SendMessage (View view) {
      Intent intent = new Intent(this, DisplayMessageActivity.class);
      EditText editText = (EditText) findViewById(R.id.edt_message);
      String message = editText.getText().toString();
      intent.putExtra(EXTRA_MESSAGE, message);
      startActivity(intent);
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      if (savedInstanceState == null) {
          getSupportFragmentManager().beginTransaction()
                  .add(R.id.container, new PlaceholderFragment())
                  .commit();
      }
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
  
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  
  /**
   * A placeholder fragment containing a simple view.
   */
  public static class PlaceholderFragment extends Fragment {
  
      public PlaceholderFragment() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_main, container, false);
          return rootView;
      }
  }
  }
  </code></pre>
  
  <p><strong>activity_layout.xml</strong></p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.example.testapp.MainActivity"
  tools:ignore="MergeRootFrame" /&gt;
  </code></pre>
  
  <p><strong>fragment_main.xml</strong></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="horizontal" &gt;
  
  &lt;EditText 
      android:id="@+id/edt_message"
      android:layout_weight="1"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:hint="@string/Message" /&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/textButtom"
      android:onClick="SendMessage" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>DisplayMessageActivity.java</strong></p>
  
  <pre><code>public class DisplayMessageActivity extends ActionBarActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_display_message);
  
      if (savedInstanceState == null) {
          getSupportFragmentManager().beginTransaction()
                  .add(R.id.container, new PlaceholderFragment()).commit();
      }
  
      Intent intent = getIntent();
      String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
  
      TextView textView = new TextView(this);
      textView.setTextSize (40);
      textView.setText (message);
  
      setContentView (textView);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  
  /**
   * A placeholder fragment containing a simple view.
   */
  public static class PlaceholderFragment extends Fragment {
  
      public PlaceholderFragment() {
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_display_message,
                  container, false);
          return rootView;
      }
  }
  
  }
  </code></pre>
  
  <p><strong>activity_display_message.xml</strong></p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context="com.example.testapp.DisplayMessageActivity"
  tools:ignore="MergeRootFrame" /&gt;
  </code></pre>
  
  <p><strong>fragment_display_message.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.testapp"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="10"
      android:targetSdkVersion="18" /&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="com.example.testapp.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="com.example.testapp.DisplayMessageActivity"
          android:label="@string/title_activity_display_message"
          android:parentActivityName="com.example.testapp.MainActivity" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="com.example.testapp.MainActivity" /&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p><strong>LogCat</strong></p>
  
  <pre><code>&gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):FATAL EXCEPTION: main 03-22
  &gt; 11:02:42.755: E/AndroidRuntime(1722):java.lang.RuntimeException:
  &gt; Unable to start activity ComponentInfo{com.example.testapp/           
  &gt; com.example.testapp.DisplayMessageActivity}:java.lang.IllegalArgumentException:
  &gt; No view found for id 0x7f05003c (com.example.testapp:id/container) for
  &gt; fragment PlaceholderFragment{417356c8 #0 id=0x7f05003c} 03-22
  &gt; 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.app.ActivityThread.access$600(ActivityThread.java:141) 03-22
  &gt; 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.os.Handler.dispatchMessage(Handler.java:99) 03-22
  &gt; 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.os.Looper.loop(Looper.java:137) 03-22 11:02:42.755:
  &gt; E/AndroidRuntime(1722):at
  &gt; android.app.ActivityThread.main(ActivityThread.java:5103) 03-22
  &gt; 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; java.lang.reflect.Method.invokeNative(Native Method) 03-22
  &gt; 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; java.lang.reflect.Method.invoke(Method.java:525) 03-22 11:02:42.755:
  &gt; E/AndroidRuntime(1722):at
  &gt; com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 03-22
  &gt; 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; dalvik.system.NativeStart.main(Native Method) 03-22 11:02:42.755:
  &gt; E/AndroidRuntime(1722):Caused by: java.lang.IllegalArgumentException:
  &gt; No view found for id 0x7f05003c (com.example.testapp:id/container) for
  &gt; fragment PlaceholderFragment{417356c8 #0 id=0x7f05003c} 03-22
  &gt; 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:919)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.app.Activity.performStart(Activity.java:5143) 03-22
  &gt; 11:02:42.755: E/AndroidRuntime(1722):at
  &gt; android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
  &gt; 03-22 11:02:42.755: E/AndroidRuntime(1722):... 11 more 03-22
  &gt; 11:02:42.965: D/dalvikvm(1722): GC_FOR_ALLOC freed 206K, 9% free
  &gt; 2808K/3076K, paused 54ms, total 92ms 03-22 11:02:44.764:
  &gt; I/Process(1722): Sending signal. PID: 1722 SIG: 9
  </code></pre>