title: ViewPager's Fragments disappear
body: <p>I'm using <code>DrawerLayout</code> with <code>ViewPagerIndicator</code>, however the last won't work correctly with the <code>DrawerLayout</code>. Once I open the application, the viewpager is displayed correctly but once I change fragments in the DrawerLayout the ViewPager's fragments disappear.</p>
  
  <p><strong><em>Here's my FragmentManager:</em></strong></p>
  
  <pre><code>FragmentManager fragmentManager = getSupportFragmentManager();
  switch (arg2) {
      case 0:
          contentFragment = new Lebanon();
          break;
  } 
  fragmentManager.beginTransaction()
          .replace(R.id.content_frame, contentFragment).commit();
  </code></pre>
  
  <p>The second fragment and fourth in the ViewPager are there and they didn't disappear, While the first, third and fifth disappear. What's wrong in my code?</p>
  
  <p><strong><em>Here's my Fragment:</em></strong></p>
  
  <pre><code>@Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      viewta = inflater.inflate(R.layout.simple_tabs, container, false);
      SamsungLB = com.androidarabia.lebanon.SamsungLB.newInstance();
      HTCLB = com.androidarabia.lebanon.HTCLB.newInstance();
      LGLB = com.androidarabia.lebanon.LGLB.newInstance();
      SonyLB = com.androidarabia.lebanon.SonyLB.newInstance();
      SearchLB = com.androidarabia.lebanon.SearchLB.newInstance();
      this.getSherlockActivity().getSupportActionBar()
              .setHomeButtonEnabled(true);
      prefs = this.getSherlockActivity().getSharedPreferences(prefName,
              Context.MODE_PRIVATE);
      adapter = new GoogleMusicAdapter(this.getSherlockActivity()
              .getSupportFragmentManager());
      pager = (ViewPager) viewta.findViewById(R.id.pager);
  
      pager.setPageTransformer(true, new ZoomOutPageTransformer());
      indicator = (TabPageIndicator) viewta.findViewById(R.id.indicator);
      pager.setCurrentItem(0);
      pager.setAdapter(adapter);
      pager.setOffscreenPageLimit(4);
      indicator.setViewPager(pager);
      return viewta;
  }
  
  private void addtabs(ViewPager pager2) {
      // TODO Auto-generated method stub
      pager2.setAdapter(adapter);
      pager2.setOffscreenPageLimit(4);
      indicator.setViewPager(pager);
  }
  
  class GoogleMusicAdapter extends FragmentStatePagerAdapter {
  
      public GoogleMusicAdapter(FragmentManager fm) {
          super(fm);
          notifyDataSetChanged();
      }
  
      @Override
      public Fragment getItem(int position) {
  
          switch (position) {
          case 0:
              return SamsungLB;
          case 1:
              return HTCLB;
          case 2:
              return LGLB;
          case 3:
              return SonyLB;
          case 4:
              return SearchLB;
  
          }
          notifyDataSetChanged();
  
          return TestFragment.newInstance(CONTENT[position % CONTENT.length]);
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
  
          return CONTENT[position % CONTENT.length].toUpperCase();
      }
  
      @Override
      public int getCount() {
  
          return CONTENT.length;
      }
  
  }
  </code></pre>