title: ViewPager Inside Fragment that is part of tabs in FragmentActivity
body: <p>I'm trying to build something that I'm not sure if it's possible. I have Fragment tabs
  (using FragmentActivity, TabHost and TabWidget as my fragment tabs container)
  and in each of the fragments I want to have, as top bar, another fragments. You can look at this as - bottom bar constructed of types of items, and top bar that would be filters. I want to snap between the filters in regular gesture. </p>
  
  <p>The behavior of my app is the following: I can see the main activity in which the first fragment sits, i can see the top/bottom bar, but i can't see the view(fragment) of the first top bar category. When I'm trying to snap to the other category nothing happens.</p>
  
  <p>This is the code for the fragment:</p>
  
  <pre><code>Public class Tab1Fragment extends Fragment {
  
  private ViewPager _mViewPager;
  private ViewPagerAdapter _adapter;
  private View child;
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      if (container == null) {
          return null;
      }
  
      child = inflater.inflate(R.layout.tab_frag1_layout, container);
  
      _mViewPager = (ViewPager) child.findViewById(R.id.viewPager);
      _adapter = new ViewPagerAdapter(GlobalContext.getAppContext(),getFragmentManager());
      _mViewPager.setCurrentItem(0);
  
      new setAdapterTask().execute();
  
      return (LinearLayout) inflater.inflate(R.layout.tab_frag1_layout,
              container, false);
  }
  
  private class setAdapterTask extends AsyncTask&lt;Void, Void, Void&gt; {
      protected Void doInBackground(Void... params) {
          return null;
      }
  
      @Override
      protected void onPostExecute(Void result) {
          _mViewPager.setAdapter(_adapter);
          _mViewPager.setCurrentItem(0);
      }
  }
  
  public void onActivityCreated(Bundle bdl) {
      super.onActivityCreated(bdl);
  
      _mViewPager.setOnPageChangeListener(new OnPageChangeListener() {
  
          @Override
          public void onPageScrollStateChanged(int position) {
          }
  
          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {
          }
  
          @Override
          public void onPageSelected(int position) {
              // TODO Auto-generated method stub
              switch (position) {
              case 0:
                  child.findViewById(R.id.first_tab).setVisibility(
                          View.VISIBLE);
                  child.findViewById(R.id.second_tab)
                          .setVisibility(View.GONE);
                  break;
  
              case 1:
                  child.findViewById(R.id.first_tab).setVisibility(View.GONE);
                  child.findViewById(R.id.second_tab).setVisibility(
                          View.VISIBLE);
                  break;
              }
          }
  
      });
  
  }
  
  }
  </code></pre>
  
  <p>This is the xml for the outer Fragment:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@color/white"
  android:orientation="vertical" &gt;  
  
  &lt;TableLayout
      style="@style/layout_f_w"
      android:stretchColumns="*" &gt;
      &lt;TableRow
          android:id="@+id/tableRow1"
          android:background="#dddddd"
          style="@style/layout_wrap"&gt;
  
            &lt;!-- First Tab --&gt;
              &lt;LinearLayout
              style="@style/layout_f_w"
              android:id="@+id/first_text"
              android:orientation="vertical" &gt;
  
                    &lt;TextView
                      android:id="@+id/textView1"
                      style="@style/text_title"
                      android:text="Tab1" /&gt;
             &lt;/LinearLayout&gt;
  
          &lt;!-- Second Tab --&gt;
              &lt;LinearLayout
              style="@style/layout_f_w"
              android:id="@+id/second_text"
              android:orientation="vertical" &gt;
  
                  &lt;TextView
                      android:id="@+id/textView1"
                      style="@style/text_title"
                      android:text="Tab2" /&gt;
  
             &lt;/LinearLayout&gt;
  
      &lt;/TableRow&gt;
   &lt;/TableLayout&gt;
   &lt;!-- Include Tab Indicator  --&gt;
   &lt;include layout="@layout/indicator" android:layout_width="fill_parent"
    android:layout_height="wrap_content"  /&gt;
  
  &lt;android.support.v4.view.ViewPager
      android:layout_width="fill_parent" android:layout_height="fill_parent"
      android:id="@+id/viewPager" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>This is an example for my first category fragment(the fragment category that inside the first fragment):</p>
  
  <pre><code>public class LayoutOne extends Fragment {
  
  
  public static Fragment newInstance(Context context) {
      LayoutOne f = new LayoutOne();  
  
      return f;
  }
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
      ViewGroup root = (ViewGroup) inflater.inflate(R.layout.layout_one, null);       
      return root;
  }
  
  }
  </code></pre>
  
  <p>Please help me :(</p>
  
  <p>This is my Fragment Adapter:</p>
  
  <pre><code>public class ViewPagerAdapter extends FragmentStatePagerAdapter {
  private Context _context;
  
  public ViewPagerAdapter(Context context, FragmentManager fm) {
      super(fm);  
      _context=context;
  
      }
  @Override
  public Fragment getItem(int position) {
      Fragment f = new Fragment();
      switch(position){
      case 0:
          f=LayoutOne.newInstance(_context);  
          break;
      case 1:
          f=LayoutTwo.newInstance(_context);  
          break;
      }
      return f;
  }
  @Override
  public int getCount() {
      return 2;
  }
  @Override
  public boolean isViewFromObject(View arg0, Object arg1) {
      // TODO Auto-generated method stub
      return false;
  }
  
  }
  </code></pre>