title: how to get progress circle before loading fragment on click of item in the navigation drawer
body: <p>I have a navigation drawer in my app.On the click of an item from the navigation drawer particular fragment gets loaded.
  but loading of a fragment is taking time of few seconds. i want a progress spinner to display in between so that it does not look like it got stuck.
  i tried for using asynchronous task but it did not work because loading fragment from  drawer does not include any background process.
  Please suggest me something.</p>
  
  <p><strong>Navigation Drawer Activity</strong></p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_test_navigation_fragments);
  
  
  
  
      toolbar = (android.support.v7.widget.Toolbar) findViewById(R.id.test_nav_tool);
      setSupportActionBar(toolbar);
  
      SharedPreferences w = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
      SharedPreferences.Editor share = w.edit();
      mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
      nvDrawer = (NavigationView) findViewById(R.id.nvView);
  
    ////if user skip-logout button in nav drawer will disable.
      loggedIn=(w.getBoolean("loggedIn", loggedIn));
      if(loggedIn==false){
          nvDrawer.getMenu().findItem(R.id.logout).setVisible(false);
      }
  
  
  
      String user_name = (w.getString("name", user));
      String type = "b";
      type=(w.getString("type", type));
      if(user_name.equalsIgnoreCase("name"))
          user_name="Guest User";
  
  
      if(type.equalsIgnoreCase("b")){
          nvDrawer.getMenu().findItem(R.id.add_kitchen).setVisible(false);
          nvDrawer.getMenu().findItem(R.id.nav_slideshow).setVisible(false);
  
      }
       header = LayoutInflater.from(this).inflate(R.layout.test_header_xml, null);
       nvDrawer.addHeaderView(header);
      TextView tv1=(TextView)header.findViewById(R.id.upload_image);
  
  
      tv1.setText(user_name);
  
      setupDrawerContent(nvDrawer);
      drawerToggle=setupDrawerToggle();
      mDrawer.addDrawerListener(drawerToggle);
      if (savedInstanceState == null) {
          nvDrawer.getMenu().performIdentifierAction(R.id.nav_camera, 0);
      }
  
  }
  private ActionBarDrawerToggle setupDrawerToggle() {
      return new ActionBarDrawerToggle(TestNavigationFragments.this, mDrawer, toolbar, R.string.drawer_open,  R.string.drawer_close);
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      if (drawerToggle.onOptionsItemSelected(item)) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  
  
  
  }
  
  
  
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
      super.onConfigurationChanged(newConfig);
      // Pass any configuration change to the drawer toggles
      drawerToggle.onConfigurationChanged(newConfig);
  }
  
  
  @Override
  protected void onPostCreate(Bundle savedInstanceState) {
      super.onPostCreate(savedInstanceState);
  
      drawerToggle.syncState();
  
  }
  
  
  private void setupDrawerContent(NavigationView navigationView) {
      navigationView.setNavigationItemSelectedListener(
              new NavigationView.OnNavigationItemSelectedListener() {
                  @Override
                  public boolean onNavigationItemSelected(MenuItem menuItem) {
  
                      selectDrawerItem(menuItem);
  
                      return true;
                  }
              });
  }
  
  
  public void selectDrawerItem(MenuItem menuItem) {
  
      Fragment fragment = null;
  
      setTitle(menuItem.getTitle());
  
      switch(menuItem.getItemId()) {
          case R.id.nav_camera:
  
  
  
              fragment=new TESTfragNEIBMAP();
              break;
          case R.id.nav_share:
              fragment =  new  TestFragACCOUNT();
              break;
          case R.id.nav_send:
              fragment = new TESTfragSUPPORT();
              break;
          case R.id.add_kitchen:
              fragment = new TestfragSELLER();
              break;
          case R.id.nav_slideshow:
              fragment=new TestAddKitchenHistory();
              break;
          case R.id.nav_gallery:
              fragment=new TestNavOrder();
              break;
          case R.id.logout:
              try {
                  SharedPreferences s = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
                  SharedPreferences.Editor editor = s.edit();
                  editor.clear().commit();
                  Intent intent = new Intent(this, Login.class);
                  intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
                  startActivity(intent);
                  finish();
                  break;
              }catch (Exception e){
                  Intent intent = new Intent(this, Login.class);
                  startActivity(intent);
              }
          case R.id.nav_track:
              fragment = new  TestTrack();
              break;
      }
  
  
      if(fragment!=null){
  
          FragmentManager fragmentManager = getSupportFragmentManager();
          fragmentManager.beginTransaction().replace(R.id.flContent, fragment).commit();
  
  
      }
  
      // Highlight the selected item has been done by NavigationView
      menuItem.setChecked(true);
      // Set action bar title
      setTitle(menuItem.getTitle());
      // Close the navigation drawer
      mDrawer.closeDrawers();
  }
  </code></pre>
  
  <p>}</p>
  
  <p><strong>UPDATE</strong>
  I have also tried writing progess code in drawer activity and dismiss it in Fragment onViewCreated() method...but i did not see any progress spinner  at the time when i click on item of drawer because map is opened and it called its onViewCreated method very fast.</p>
  
  <p>the other option can be adding splash screen on click of item in drawer till map will load but i don't have idea how to do it like how to finish splash screen when the map will become properly visible.</p>