title: Android TabLayout does not display contents anymore as soon as fragment is switched
body: <p>I am using a navigation drawer in my project, with 5 fragments in it. In one fragment I have the in the design support library introduced TabLayout, which includes 2 Fragments. All works fine, except when I leave the fragment which has the TabLayout and switch back to it, all the content is gone. </p>
  
  <p>In each fragment in the TabLayout I have a SwipeRefreshLayout with a ListView in it, they both don't display anything upon switch.</p>
  
  <p>I also noticed the TabLayout starts acting strange. by strange I mean the white indicator starts jumping, you are able to hold it still in the middle of the two tab...</p>
  
  <p>So am I missing something that the TabLayout acts so strange?</p>
  
  <p>The code here:
  Fragment which contains the TabLayout:</p>
  
  <pre><code>public class MainFragment extends Fragment {
      private static String locale;
      private static ViewPager viewPager;
      private static TabLayout tabLayout;
  
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          Utils.changeLanguage(getActivity());
  
          final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.MyStyle);
  
          LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);
  
          View view = localInflater.inflate(R.layout.fragment1, container, false);
  
          viewPager = (ViewPager) view.findViewById(R.id.viewpager);
          tabLayout = (TabLayout) view.findViewById(R.id.tabs);
  
          return view;
      }
  
      @Override
      public void onActivityCreated(Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
  
          setupViewPager(viewPager);
          tabLayout.setupWithViewPager(viewPager);
      }
  
      private void setupViewPager(ViewPager viewPager) {
          LinesTabsAdapter adapter = new LinesTabsAdapter(getActivity().getSupportFragmentManager());
          adapter.addFragment(new Fragment1(), "Fragment 1");
          adapter.addFragment(new Fragment2(), "Fragment2");
          viewPager.setAdapter(adapter);
      }
  
  
      public static class Fragment extends Fragment {
          private static List&lt;RowItems1&gt; rowItems;
          private static ListView listview;
          private static Adapter1 adapter;
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
              View view = inflater.inflate(R.layout.activity1, container, false);
  
              listview = (ListView) view.findViewById(R.id.listview1);
  
              return view;
          }
  
          @Override
          public void onActivityCreated(Bundle savedInstanceState) {
              super.onActivityCreated(savedInstanceState);
  
              updateInfo(true);
          }
  
          public static void updateInfo() {
              rowItems = new ArrayList&lt;&gt;();
              adapter = new Adapter1(context, rowItems);
             listview.setAdapter(adapter);
          }
      }
  
      public static class Fragment2 extends Fragment {
          private static List&lt;RowItems2&gt; rowItems;
          private static ListView listview;
          private static Adapter1 adapter;
  
          @Override
          public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
              View view = inflater.inflate(R.layout.activity_lines_all, container, false);
  
              listview = (ListView) view.findViewById(R.id.activity2);
  
              return view;
          }
  
          @Override
          public void onActivityCreated(Bundle savedInstanceState) {
              super.onActivityCreated(savedInstanceState);
  
              updateInfo(true);
          }
  
          public static void updateInfo() {
              rowItems = new ArrayList&lt;&gt;();
              adapter = new Adapter2(context, rowItems);
              listview.setAdapter(adapter);
          }
      }
  }
  </code></pre>
  
  <p>I am using the MainFragment as a singleton and replacing the content with it as soon as the user selects it in the navigation drawer. When I switch to it, everything works fine, the ListView contains its data, the SwipeRefreshLayout works fine. When I switch to another fragment using the navigation drawer and switch back to this fragment, it displays nothing, as described above.</p>
  
  <p>EDIT: Am I the only one having trouble with this? If anyone had problems, how did they fix it?</p>