title: Android Two Fragments in Same Activity
body: <p>I am aware of the following post:
  <a href="https://stackoverflow.com/questions/4949216/using-multiple-fragments-in-an-single-activity">Using Multiple Fragments in an single activity</a></p>
  
  <p>What I am looking for is a specific answer to a specific problem. The result of the following code is a blank FragmentActivity. What am I missing in my following code to get it to render an activity with two fragments. One is a empty list fragment, the other is a fragment which contains a input box and a button in a horizontal layout, (this layout can be found at <a href="http://developer.android.com/training/basics/firstapp/starting-activity.html" rel="noreferrer">http://developer.android.com/training/basics/firstapp/starting-activity.html</a>) that I want to be placed absolutely at the bottom of the screen with a fixed height of about 25 dip.</p>
  
  <p>Manifest.xml</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.my.package"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="17" /&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.my.package.Application"
              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;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>My main activity and its associated application.xml file. </p>
  
  <pre><code>package com.my.package;
  
  import android.os.Bundle;
  import android.support.v4.app.FragmentActivity;
  import android.support.v4.app.FragmentTransaction;
  
  public class Application  
  extends FragmentActivity 
  implements MessageListViewFragment.OnLineSelectedListener, 
  SendMessageFragment.OnSendButtonPressed {
  
      MessageListViewFragment mMessageListFragment;
      SendMessageFragment mSendMessageFragment;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.application);
  
          mMessageListFragment = new MessageListViewFragment();
          mSendMessageFragment = new SendMessageFragment();
  
          FragmentTransaction transaction = 
                  getSupportFragmentManager().beginTransaction();
  
          transaction.add(R.id.message_fragment, mMessageListFragment);
          transaction.add(R.id.send_fragment, mSendMessageFragment);
  
          transaction.commit();
      }
  
      @Override
      public void onListItemSelected(int position) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onSendButtonPressed() {
          // TODO Auto-generated method stub
  
      }
  }
  </code></pre>
  
  <p>Layout:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:baselineAligned="false"
      android:orientation="vertical" &gt;
  
      &lt;fragment
          android:id="@+id/message_fragment"
          android:name="com.example.android.fragments.MessageListViewFragment"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:gravity="top" /&gt;
  
      &lt;fragment
          android:id="@+id/send_fragment"
          android:name="com.example.android.fragments.SendMessageFragment"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:gravity="bottom" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And now for the two fragments and their associated xml files:
  First Fragment (list fragment at top)</p>
  
  <pre><code>package com.my.package;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.support.v4.app.ListFragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  public class MessageListViewFragment extends ListFragment {
      OnLineSelectedListener mCallback;
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
  
          // This makes sure that the container activity has implemented
          // the callback interface. If not, it throws an exception
          try {
              mCallback = (OnLineSelectedListener)activity;
          } catch (ClassCastException e) {
              throw new ClassCastException(activity.toString()
                      + " must implement OnLineSelectedListener");
          }
      }
  
      // Container Activity must implement this interface
      public interface OnLineSelectedListener {
          public void onListItemSelected(int position);
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, 
              ViewGroup container, Bundle savedInstanceState) {
  
          return inflater.inflate(R.layout.list_fragment, null);
      }
  }
  </code></pre>
  
  <p>Layout:</p>
  
  <pre><code>&lt;FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/fragment_container"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  </code></pre>
  
  <p>second fragment (at bottom)</p>
  
  <pre><code>package com.my.package;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  public class SendMessageFragment extends Fragment {
      OnSendButtonPressed mCallback;
  
      // Container Activity must implement this interface
      public interface OnSendButtonPressed {
          public void onSendButtonPressed();
      }
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
      }
  
      @Override
      public View onCreateView(LayoutInflater inflater, 
              ViewGroup container, Bundle savedInstanceState) {
  
          return inflater.inflate(R.layout.input_fragment, null);
      }
  
      @Override
      public void onAttach(Activity activity) {
          super.onAttach(activity);
  
          // This makes sure that the container activity has implemented
          // the callback interface. If not, it throws an exception
          try {
              mCallback = (OnSendButtonPressed)activity;
          } catch (ClassCastException e) {
              throw new ClassCastException(activity.toString()
                      + " must implement OnHeadlineSelectedListener");
          }
      }
  }
  </code></pre>
  
  <p>Layout:</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/edit_message"
          android:layout_weight="1"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:hint="@string/edit_message" /&gt;
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/button_send" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>