title: Handling the backstack with fragments containing tabs
body: <p>I'm trying to create an Android application which contains a single activity with a container and a navigation drawer. The initialy empty container loads fragments which has a <code>ViewPager</code> inside a tab layout in which I load a frgment with a <code>FragmentTransaction</code>:</p>
  
  <pre><code>public static void replaceFragmentInContainer(FragmentManager fragmentManager, Fragment fragmentToShow,
          boolean addToBackStack)
  {
      FragmentTransaction transaction = fragmentManager.beginTransaction();
      if (addToBackStack)
      {
          transaction.addToBackStack(null);
      }
      transaction.replace(R.id.container, fragmentToShow);
      transaction.commit();
  }
  </code></pre>
  
  <p>I'm using v4 fragments with a v7 <code>ActionBar</code> in a v7 <code>ActionBarActivity</code>.</p>
  
  <p>Every loaded fragment is a fragment which only loads tabs with other fragments which they hold the actual usability. An example of such tab loading fragment:</p>
  
  <pre><code>public class MainFragment extends TabsFragment
  {
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
      {
          super.onCreateView(inflater, container, savedInstanceState);
          View contentView = inflater.inflate(R.layout.fragment_main, container, false);
          initTabsLayout(savedInstanceState, contentView, R.id.pager);
          addTab("tabspectag1", "", R.drawable.draw1, Fragment1.class, null);
          addTab("tabspectag2", "", R.drawable.draw2, Fragment2.class, null);
          addTab("tabspectag3", "", R.drawable.draw3, Fragment3.class, null);
          return contentView;
      }
  </code></pre>
  
  <p>The problem I'm facing is with the backstack. When a fragment is added to the backstack and I press the back button, the app does go back to the previous fragment like I want to and I see the tabs layout itself, but the content of the tabs is empty like there was nothing loaded to that tab. When it happens, I manage to reload the tab's content only when choosing that screen again with the navigational drawer.</p>
  
  <p>I've tried overriding the <code>onBackPressed</code> in the activity:</p>
  
  <pre><code>@Override
  public void onBackPressed()
  {
      if (getFragmentManager().getBackStackEntryCount() &gt; 0)
      {
          getFragmentManager().popBackStack();
      } else
      {
          super.onBackPressed();
      }
  }
  </code></pre>
  
  <p>but that like I said, it's like I'm getting back to the previous fragment but the tab inside that fragment is not repainting the fragment it had.</p>
  
  <p>What can be done to solve this issue?</p>
  
  <p>Since I DO see the tabs layout of the original fragment in the backstack but not the fragment inside the tab, is it possible I just need to somehow refresh the tab content meaning repaint it? If I can do such a thing then how can I do it?</p>