title: Android: Drawer menu + swipeView
body: <p>I would like to implement a swipe views into my Sherlock fragments with the drawer menu.
  I did it and it seems works fine, owever, there is a minor issue that i can't figure out.</p>
  
  <p>So let's begin with some pices of my code:</p>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>public class MainActivity extends SherlockFragmentActivity {
  
      // Declare Variable
      DrawerLayout mDrawerLayout;
      ListView mDrawerList;
      ActionBarDrawerToggle mDrawerToggle;
      MenuListAdapter mMenuAdapter;
      String[] title;
      String[] subtitle;
      int[] icon;
      Fragment fragment1 = new TestFragment();
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.drawer_main);
  
          // Generate title
          title = new String[] { "Test title" };
  
          // Generate subtitle
          subtitle = new String[] { "Test subtitle" };
  
          // Generate icon
          icon = new int[] { R.drawable.action_about };
  
          // Locate DrawerLayout in drawer_main.xml
          mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  
          // Locate ListView in drawer_main.xml
          mDrawerList = (ListView) findViewById(R.id.left_drawer);
  
          // Set a custom shadow that overlays the main content when the drawer
          // opens
          mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow,
                  GravityCompat.START);
  
          // Pass results to MenuListAdapter Class
          mMenuAdapter = new MenuListAdapter(this, title, subtitle, icon);
  
          // Set the MenuListAdapter to the ListView
          mDrawerList.setAdapter(mMenuAdapter);
  
          // Capture button clicks on side menu
          mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
  
          // Enable ActionBar app icon to behave as action to toggle nav drawer
          getSupportActionBar().setHomeButtonEnabled(true);
          getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
          // ActionBarDrawerToggle ties together the the proper interactions
          // between the sliding drawer and the action bar app icon
          mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
                  R.drawable.ic_drawer, R.string.drawer_open,
                  R.string.drawer_close) {
  
              public void onDrawerClosed(View view) {
                  // TODO Auto-generated method stub
                  super.onDrawerClosed(view);
              }
  
              public void onDrawerOpened(View drawerView) {
                  // TODO Auto-generated method stub
                  super.onDrawerOpened(drawerView);
              }
          };
  
          mDrawerLayout.setDrawerListener(mDrawerToggle);
  
          if (savedInstanceState == null) {
              selectItem(0);
          }
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          getSupportMenuInflater().inflate(R.menu.activity_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
  
          if (item.getItemId() == android.R.id.home) {
  
              if (mDrawerLayout.isDrawerOpen(mDrawerList)) {
                  mDrawerLayout.closeDrawer(mDrawerList);
              } else {
                  mDrawerLayout.openDrawer(mDrawerList);
              }
          }
  
          return super.onOptionsItemSelected(item);
      }
  
      // The click listener for ListView in the navigation drawer
      private class DrawerItemClickListener implements
              ListView.OnItemClickListener {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
                  long id) {
              selectItem(position);
          }
      }
  
      private void selectItem(int position) {
  
          FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
          // Locate Position
          switch (position) {
          case 0:
              ft.replace(R.id.content_frame, fragment1);
              break;
          ft.commit();
          mDrawerList.setItemChecked(position, true);
          // Close drawer
          mDrawerLayout.closeDrawer(mDrawerList);
      }
  
      @Override
      protected void onPostCreate(Bundle savedInstanceState) {
          super.onPostCreate(savedInstanceState);
          // Sync the toggle state after onRestoreInstanceState has occurred.
          mDrawerToggle.syncState();
      }
  
      @Override
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
          // Pass any configuration change to the drawer toggles
          mDrawerToggle.onConfigurationChanged(newConfig);
      }
  }
  </code></pre>
  
  <p><strong>TestFragment:</strong></p>
  
  <pre><code>public class TestFragment extends SherlockFragment {
  
      ViewPager mViewPager;
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.test, container, false);
  
          mViewPager = (ViewPager) rootView.findViewById(R.id.viewpager);
          PagerTabStrip pagerTabStrip = (PagerTabStrip) rootView.findViewById(R.id.pagerTabStrip);
  
          testAdapter titleAdapter = new testAdapter(getFragmentManager());
          mViewPager.setAdapter(titleAdapter);
          mViewPager.setCurrentItem(0);
  
          return rootView;
      }
  
  }
  </code></pre>
  
  <p><strong>testAdapter</strong></p>
  
  <pre><code>public class testAdapter extends FragmentPagerAdapter {
      private String titles[] = new String[]{"View1","View2"};
      private Fragment frags[] = new Fragment[titles.length];
  
  public systemAdapter(FragmentManager fm) {
      super(fm);
      frags[0] = new testSwipe1();
      frags[1] = new testSwipe2();
  }
  
  @Override
  public CharSequence getPageTitle (int position){
      Log.v("TitleAdapter - getPageTitle=", titles[position]);
      return titles[position];
  }
  
  @Override
  public Fragment getItem(int position) {
      Log.v("TitleAdapter - getItem=", String.valueOf(position));
      return frags[position];
  }
  
  @Override
  public int getCount() {
      return frags.length;
  }
  </code></pre>
  
  <p><strong>testSwipe1 and testSwipe2 are the same:</strong></p>
  
  <pre><code>public class testSwipe1 extends SherlockFragment {
  
      public View onCreateView(LayoutInflater inflater, ViewGroup container,          Bundle savedInstanceState) {        View rootView = inflater.inflate(R.layout.testswipe_layout, container, false);
  
          ImageButton testImage = (ImageButton) rootView.findViewById(R.id.test);
  
          //todo function image
  
          return rootView; 
  }
  
  }
  </code></pre>
  
  <p>Ok, the drawer works fine and if i tap on "test title" it inflate the layout with the swipe and i can see the image in the 2 test swipe views.
  Owever, if i open back the drawer and tap again on "test title" i can see the swipe views without the images on my swipe fragment layout. If i put the device in landscape and back to portrait, the image on my swipe fragments come back! open drawer -> tap again on test title -> images disappear.... -> landscaper -> portrait -> image back. </p>
  
  <p>The layouts defined are standard for drawer and swipeviews. inside the swipeviews fragments layout there is only an imageview. So the issue must be in the java part but i can't figure out where.
  Any helps?</p>