title: Launch new activity after clicking a button
body: <p>I'm new to Android and am following the example <a href="http://developer.android.com/training/basics/firstapp/starting-activity.html" rel="nofollow">here</a>. I can get the Layout fine, and the button event fires, but Android Studio doesn't seem to work in the same way as Eclipse does in their example. </p>
  
  <p>I add a new Activity but Android Studio forces a new Fragment to be added as well. I've read up on Fragments but don't understand why we're forced to use it in AS but not in Eclipse. Either way, this seems to be breaking my app. When I click the button I get an error saying</p>
  
  <blockquote>
    <p>java.lang.RuntimeException: Unable to start activity
    ComponentInfo{com.t.at/com.t.at.DisplayMessageActivity}:
    java.lang.IllegalArgumentException: No view found for id 0x7f07003c
    (com.tutorials.androidtutorials:id/container) for fragment
    PlaceholderFragment{b1e1f5e8 #0 id=0x7f07003c}</p>
  </blockquote>
  
  <p>I'm sure I've followed everything the tutorial has said but the only difference I see is the fragment file that AS always creates. How can I launch a new activity after clicking a button? Here's my click handler</p>
  
  <pre><code>public void sendMessage(View view){
      Intent intent = new Intent(this, DisplayMessageActivity.class);
      EditText editText = (EditText)findViewById(R.id.edit_message);
      String message = editText.getText().toString();
      intent.putExtra(EXTRA_MESSAGE, message);
      startActivity(intent);
  }
  </code></pre>
  
  <p>My activity_displaymessage.xml file looks like this</p>
  
  <pre><code>&lt;FrameLayout 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"
      tools:context=".DisplayMessageActivity"
      tools:ignore="MergeRootFrame" /&gt;
  </code></pre>
  
  <p>and fragment_displaymessage.xml</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"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin"
      tools:context=".DisplayMessageActivity$PlaceholderFragment"&gt;
  
      &lt;TextView
          android:text="@string/hello_world"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>As requested in comments, here's the Fragment code</p>
  
  <pre><code>public class DisplayMessageActivity extends ActionBarActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_displaymessage);
  
          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.display_message, 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.
          switch (item.getItemId()) {
              case R.id.action_settings:
                  return true;
              case android.R.id.home:
                  NavUtils.navigateUpFromSameTask(this);
                  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_displaymessage, container, false);
              return rootView;
          }
      }
  
  }
  </code></pre>