title: java.lang.IllegalArgumentException: No view found for id 0x7f0c0050
body: <p>I am trying to create an android app that consist of fragments in a tab activity. The tab consists of Fragment A and Fragment B(HistoryInfoFragment). Fragment B have a button for the user to click and it will shows Fragment C(HistoryDetailFragment). However, when I run the app the following error was thrown: </p>
  
  <blockquote>
    <p>java.lang.IllegalArgumentException: No view found for id 0x7f0c0050 (com.example.test.interfacev2:id/frame_container) for fragment HistoryDetailFragment</p>
  </blockquote>
  
  <p>I had refered to several other questions but still encountering the problem. Here are my codes.</p>
  
  <p>TabActivity.java</p>
  
  <pre><code>public class TabActivity extends FragmentActivity implements ActionBar.TabListener {
  
      private ViewPager viewPager;
      private TabsPagerAdapter mAdapter;
      private ActionBar actionBar;
      // Tab titles
      private String[] tabs = { "Current", "History"};
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.tab_activity);
  
          // Initilization
          viewPager = (ViewPager) findViewById(R.id.pager);
          actionBar = getActionBar();
          mAdapter = new TabsPagerAdapter(getSupportFragmentManager());
  
          viewPager.setAdapter(mAdapter);
          actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
  
          // Adding Tabs
          for (String tab_name : tabs) {
              actionBar.addTab(actionBar.newTab().setText(tab_name)
                  .setTabListener(this));
          }
  
          viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  
              @Override
              public void onPageSelected(int position) {
                  // on changing the page
                  // make respected tab selected
                  actionBar.setSelectedNavigationItem(position);
              }
  
              @Override
              public void onPageScrolled(int arg0, float arg1, int arg2) {
              }
  
              @Override
              public void onPageScrollStateChanged(int arg0) {
              }
          });
      }
  } 
  </code></pre>
  
  <p>HistoryInfoFragment.java</p>
  
  <pre><code>public class HistoryInfoFragment extends Fragment implements View.OnClickListener {
  
      @Nullable
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
          View view = inflater.inflate(R.layout.history_fragment, container, false);
          Button bth = (Button)view.findViewById(R.id.btn);
          bth.setOnClickListener(this);
          return view;
      }
  
      @Override
      public void onClick(View v) {
          Fragment fragment = null;
          fragment = new HistoryDetailFragment();
          FragmentManager fragmentManager = getFragmentManager();
          // this is the line that throw the exception
          fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
      }
  }
  </code></pre>
  
  <p>tabactivity.xml</p>
  
  <pre><code>&lt;android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/pager"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  &lt;/android.support.v4.view.ViewPager&gt;
  </code></pre>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/drawer_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;!-- Framelayout to display Fragments --&gt;
      &lt;FrameLayout
          android:id="@+id/frame_container"
          android:layout_width="match_parent"
          android:layout_height="match_parent" /&gt;
  &lt;/android.support.v4.widget.DrawerLayout&gt;
  </code></pre>
  
  <p>history_fragment.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="history"/&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="submit"
          android:id="@+id/btn" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>history_detail_fragment.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="history detail"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Any help will be appreciated. Thanks.</p>
  
  <p>Edit: add stack trace.
  Not sure if this is the correct stack trace.</p>
  
  <pre><code>08-16 08:35:25.148    2162-2162/com.example.test.interfacev2 W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d52b20)
  08-16 08:35:25.156    2162-2162/com.example.test.interfacev2 E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: com.example.test.interfacev2, PID: 2162
  java.lang.IllegalArgumentException: No view found for id 0x7f0c0050 (com.example.test.interfacev2:id/frame_container) for fragment HistoryDetailFragment{52a755dc #2 id=0x7f0c0050}
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
          at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
          at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
          at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
          at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458)
          at android.os.Handler.handleCallback(Handler.java:733)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:136)
          at android.app.ActivityThread.main(ActivityThread.java:5001)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>