title: How to avoid sliding menu lag which causes stuttering in opening the fragment?
body: <p>In my application i have implemented the Sliding menu drawer in the main activity.
  The design of the menu is customized and on click of listitem from the menu a fragment opens.</p>
  
  <pre><code>private class SlideMenuClickListener implements
          ListView.OnItemClickListener {
      @Override
      public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,
                              long id) {
          // display view for selected nav drawer item
          displayView(position);
      }
  }
  private void displayView(int position) {
      // update the main content by replacing fragments
      Fragment fragment = null;
      switch (position) {
          case 0:
              fragment=new LastTransactionsDetails();
  
              break;
          case 1:
              fragment = new Statement_of_Transaction();
              break;
         case 2:
            fragment = new AccountDetails();
  
              break;
          case 3:
              fragment=new ProfileSetting();
  
              break;
             case 4:
              fragment=new LastTransactionsDetails();
  
              break;
  
          default:
              break;
      }
  
      if (fragment != null) {
  
          FragmentManager fragmentManager = getSupportFragmentManager();
          fragmentManager.beginTransaction().replace(R.id.frame_container, fragment).commit();
          // update selected item and title, then close the drawer
          mDrawerList.setItemChecked(position, true);
          mDrawerList.setSelection(position);
          setTitle(navMenuTitles[position]);
          mDrawerLayout.closeDrawer(mDrawerList);
      } else {
          // error in creating fragment
          Log.e("MainActivity", "Error in creating fragment");
      }
  }
  </code></pre>
  
  <p>The closing of sliding menu shows a bit delay which causes stuttering of the menu. The fragment onCreateView is calling an async task containing calls to webservice methods. Is it because of the fragment loading that is causing the lag? If so then what change do i have make?
  The fragment code is as follows : </p>
  
  <pre><code>@Override
  public void onAttach(Context context) {
      super.onAttach(context);
  
      mActivity = context instanceof Activity ? (Activity) context : null;
      viewUtils = new ViewUtils(mActivity);
      webServicesParams = new WebServicesParams(mActivity);
      database = new DbAdapter(context);
      database.createDatabase();
      database.open();
      parseJsonResponse = new ParseJsonResponse();
      showProgressDialog();
  
  }
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  
      View rootView = inflater.inflate(R.layout.last_transactions_details, container, false);
  
      listView_transactions = (ListView) rootView.findViewById(R.id.listView_transactions);
  
      try {
  
  
          String jsonResponse = webServicesParams.Last_Transaction();
          arr_last_trans = parseJsonResponse.getTierDetails(jsonResponse);
  
          adapter = new LastTransactionAdapter(arr_last_trans,getActivity());
          listView_transactions .setAdapter(adapter);
  
          dismissProgressDialog();
      }
  </code></pre>