title: Switching fragments in Sliding Menu?
body: <p>There's a time come when someone include some codes without explaining. Well, this time it's this case because the codes aren't hard at all.
  I'm trying to switch fragments in sliding drawer.
  Codes:</p>
  
  <pre><code>    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
  </code></pre>
  
  <p><strong>Here's DrawerItemClickListener Class:</strong></p>
  
  <pre><code>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) {
      FragmentManager manager = getSupportFragmentManager();
      FragmentTransaction ft = manager.beginTransaction();
      Fragment frag = null;
      switch (position) {
      case 0:
          ft.replace(R.id.content_frame, Algeria);
          break;
      case 1:
          ft.replace(R.id.content_frame, Bahrain);
  
          break;
      case 2:
          ft.replace(R.id.content_frame, Comoros);
          break;
      case 3:
          ft.replace(R.id.content_frame, Djibouti);
          break;
      case 4:
          ft.replace(R.id.content_frame, Egypt);
          break;
      case 5:
          ft.replace(R.id.content_frame, Iraq);
          break;
      case 6:
          ft.replace(R.id.content_frame, Jordan);
          break;
      case 7:
          ft.replace(R.id.content_frame, Kuwait);
          break;
      case 8:
          ft.replace(R.id.content_frame, Lebanon);
          break;
      case 9:
          ft.replace(R.id.content_frame, Libya);
          break;
      case 10:
          ft.replace(R.id.content_frame, Mauritania);
          break;
      case 11:
          ft.replace(R.id.content_frame, Morocco);
          break;
      case 12:
          ft.replace(R.id.content_frame, Oman);
          break;
      case 13:
          ft.replace(R.id.content_frame, Pelastine);
          break;
      case 14:
          ft.replace(R.id.content_frame, Qatar);
          break;
      case 15:
          ft.replace(R.id.content_frame, Saudi_Arabia);
          break;
      case 16:
          ft.replace(R.id.content_frame, Somalia);
          break;
      case 17:
          ft.replace(R.id.content_frame, Sudan);
          break;
      case 18:
          ft.replace(R.id.content_frame, Syria);
          break;
      case 19:
          ft.replace(R.id.content_frame, Tunisia);
          break;
      case 20:
          ft.replace(R.id.content_frame, Emirates);
          break;
      case 21:
          ft.replace(R.id.content_frame, Yemen);
          break;
      }
      ft.commit();
  
  }
  </code></pre>
  
  <p><strong>BUT IT DOESN'T WORK</strong>
  No bugs at all, just nothing show at the screen! i know the fragment work 100% but it doesn't show on the screen. Well WHY!?
  Thanks. :)</p>
  
  <p><strong>UPDATE FUL CODES</strong>:</p>
  
  <pre><code>public class Drawer extends SherlockFragmentActivity {
      MenuListAdapter mMenuAdapter;
      String[] title;
      String[] subtitle;
      int[] icon;
      SharedPreferences prefs;
      public static String prefName = "SecretFile";
      Fragment Algeria = new Fragment1();
      Fragment Bahrain = new Fragment2();
      Fragment Comoros = new Fragment3();
      Fragment Djibouti = new Fragment4();
      Fragment Egypt = new Fragment5();
      Fragment Iraq = new Fragment6();
      Fragment Jordan = new Jordan();
      Fragment Kuwait = new Fragment8();
      Fragment Lebanon = new Lebanon();
      Fragment Libya = new Fragment10();
      Fragment Mauritania = new Fragment11();
      Fragment Morocco = new Fragment12();
      Fragment Oman = new Fragment13();
      Fragment Pelastine = new Fragment14();
      Fragment Qatar = new Qatar();
      Fragment Saudi_Arabia = new Fragment16();
      Fragment Somalia = new Fragment17();
      Fragment Sudan = new Fragment18();
      Fragment Syria = new Fragment19();
      Fragment Tunisia = new Fragment20();
      Fragment Emirates = new Fragment21();
      Fragment Yemen = new Fragment22();
      ConnectivityManager connMgr;
      NetworkInfo networkInfo;
      ListView mDrawerList;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          SlidingMenu sm = new SlidingMenu(this);
          title = getResources().getStringArray(R.array.country_array);
          icon = new int[] { R.drawable.algeria, R.drawable.bahrain,
                  R.drawable.comoros, R.drawable.djibouti, R.drawable.egypt,
                  R.drawable.iraq, R.drawable.jordan, R.drawable.kuwait,
                  R.drawable.lebanon, R.drawable.libya, R.drawable.mauritania,
                  R.drawable.morocco, R.drawable.oman, R.drawable.pelastine,
                  R.drawable.qatar, R.drawable.saudiarabia, R.drawable.somalia,
                  R.drawable.sudan, R.drawable.syria, R.drawable.tunisia,
                  R.drawable.emirates, R.drawable.yemen, };
          sm.setMenu(R.layout.drawer_main);
          sm.setShadowWidthRes(R.dimen.shadow_width);
          sm.setShadowDrawable(R.drawable.shadow);
          sm.setMode(SlidingMenu.LEFT_RIGHT);
          sm.setBehindOffsetRes(R.dimen.slidingmenu_offset);
          sm.setFadeDegree(0.7f);
          sm.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN);
          getActionBar().setDisplayHomeAsUpEnabled(true);
          sm.setSecondaryMenu(R.layout.menu_frame);
          sm.setSecondaryShadowDrawable(R.drawable.shadow);
          sm.attachToActivity(this, SlidingMenu.SLIDING_WINDOW);
          mDrawerList = (ListView) findViewById(R.id.left_drawer);
          mMenuAdapter = new MenuListAdapter(this, title, icon);
          mDrawerList.setAdapter(mMenuAdapter);
          mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
  
      }
  
      private int seethefirstactivity() {
          // TODO Auto-generated method stub
          int fragmento;
          connMgr = (ConnectivityManager) this
                  .getSystemService(Context.CONNECTIVITY_SERVICE);
          networkInfo = connMgr.getActiveNetworkInfo();
          fragmento = prefs.getInt("country", 1);
          if (fragmento == 0) {
              Algeria = new Fragment1();
  
          } else if (fragmento == 1) {
              Bahrain = new Fragment2();
  
          } else if (fragmento == 2) {
              Comoros = new Fragment3();
  
          } else if (fragmento == 3) {
              Djibouti = new Fragment4();
  
          } else if (fragmento == 4) {
              Egypt = new Fragment5();
  
          } else if (fragmento == 5) {
              Iraq = new Fragment6();
  
          } else if (fragmento == 6) {
              Jordan = new Jordan();
  
          } else if (fragmento == 7) {
              Kuwait = new Fragment8();
  
          } else if (fragmento == 8) {
  
              Lebanon = new Lebanon();
  
          } else if (fragmento == 9) {
              Libya = new Fragment10();
  
          } else if (fragmento == 10) {
              Mauritania = new Fragment11();
  
          } else if (fragmento == 11) {
              Morocco = new Fragment12();
  
          } else if (fragmento == 12) {
              Oman = new Fragment13();
  
          } else if (fragmento == 13) {
              Pelastine = new Fragment14();
  
          } else if (fragmento == 14) {
              Qatar = new Qatar();
  
          } else if (fragmento == 15) {
              Saudi_Arabia = new Fragment16();
  
          } else if (fragmento == 16) {
              Somalia = new Fragment17();
  
          } else if (fragmento == 17) {
              Sudan = new Fragment18();
  
          } else if (fragmento == 18) {
              Syria = new Fragment19();
  
          } else if (fragmento == 19) {
              Tunisia = new Fragment20();
  
          } else if (fragmento == 20) {
              Emirates = new Fragment21();
  
          } else if (fragmento == 21) {
              Yemen = new Fragment22();
  
          }
          return fragmento;
      }
  
      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) {
          FragmentManager manager = getSupportFragmentManager();
          FragmentTransaction ft = manager.beginTransaction();
          Fragment frag = null;
          switch (position) {
          case 0:
              ft.replace(R.id.content_frame, Algeria);
              break;
          case 1:
              ft.replace(R.id.content_frame, Bahrain);
  
              break;
          case 2:
              ft.replace(R.id.content_frame, Comoros);
              break;
          case 3:
              ft.replace(R.id.content_frame, Djibouti);
              break;
          case 4:
              ft.replace(R.id.content_frame, Egypt);
              break;
          case 5:
              ft.replace(R.id.content_frame, Iraq);
              break;
          case 6:
              ft.replace(R.id.content_frame, Jordan);
              break;
          case 7:
              ft.replace(R.id.content_frame, Kuwait);
              break;
          case 8:
              ft.replace(R.id.content_frame, Lebanon);
              break;
          case 9:
              ft.replace(R.id.content_frame, Libya);
              break;
          case 10:
              ft.replace(R.id.content_frame, Mauritania);
              break;
          case 11:
              ft.replace(R.id.content_frame, Morocco);
              break;
          case 12:
              ft.replace(R.id.content_frame, Oman);
              break;
          case 13:
              ft.replace(R.id.content_frame, Pelastine);
              break;
          case 14:
              ft.replace(R.id.content_frame, Qatar);
              break;
          case 15:
              ft.replace(R.id.content_frame, Saudi_Arabia);
              break;
          case 16:
              ft.replace(R.id.content_frame, Somalia);
              break;
          case 17:
              ft.replace(R.id.content_frame, Sudan);
              break;
          case 18:
              ft.replace(R.id.content_frame, Syria);
              break;
          case 19:
              ft.replace(R.id.content_frame, Tunisia);
              break;
          case 20:
              ft.replace(R.id.content_frame, Emirates);
              break;
          case 21:
              ft.replace(R.id.content_frame, Yemen);
              break;
          }
          ft.commit();
  
      }
  
  }
  </code></pre>