title: android viewpager with tablayout - how to add other fragments inside of a tab?
body: <p>so i have the classic viewpager in a tablayout that looks something like this:
  <a href="https://i.stack.imgur.com/LqF0J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LqF0J.png" alt="enter image description here"></a></p>
  
  <p>My viewPagerAdapter class looks like this:</p>
  
  <p>public class HomePagerAdapter extends FragmentPagerAdapter {
      int mNumOfTabs;</p>
  
  <pre><code>public HomePagerAdapter(FragmentManager fm, int NumOfTabs) {
      super(fm);
      this.mNumOfTabs = NumOfTabs;
  }
  
  @Override
  public Fragment getItem(int position) {
  
      switch (position) {
          case 0:
              TabHomeFragment tab1 = new TabHomeFragment();
              return tab1;
          case 1:
              TabShopFragment tab2 = new TabShopFragment();
              return tab2;
          case 2:
              TabMeFragment tab3 = new TabMeFragment();
              return tab3;
          default:
              return null;
      }
  }
  
  @Override
  public int getCount() {
      return mNumOfTabs;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>So now on one of the tabs i need to add a fragment on top of it.  so its a search fragment really. i do a search in the tab bar and i want the back end search results to appear in only ONE of the tabs (the first one).  but i want the search results displayed in a fragment called searchFragmentResults and i want it to be laid out on top of the first tab. Then when user hits the back button it will just go back to the original content in the first tab.  Is this possible with view pager ?</p>
  
  <p>so visually when i hit the search icon on the first tabs tabBar it should bring up a searchView and when i search for the users query it should bring up a another fragment with the results but only in the tab that it started from. Here is an example:
  <a href="https://i.stack.imgur.com/YBYFb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YBYFb.png" alt="enter image description here"></a></p>
  
  <p>i cant call <code>fragtransaction.replace(somecontentview, somefragment); (or its add method)</code> because i did not add them to a contentview. i let the viewpager do it for me.  So how is this achieved ?</p>