title: ProgressBar not showing, android
body: <p>Here is my code:</p>
  
  <pre><code>    automaticCountryButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
  
  
              progressBar.setVisibility(View.VISIBLE);
  
              if (ContextCompat.checkSelfPermission(HomeActivity.this,
                      Manifest.permission.ACCESS_FINE_LOCATION)
                      != PackageManager.PERMISSION_GRANTED){
                  setUpLocationPermission();
                  return;
  
              }
  
              Log.d(TAG, String.valueOf(gps.canGetLocation()));
              Log.d(TAG, String.valueOf(gps.getLocation()));
              Log.d(TAG, String.valueOf(gps.getLatitude()));
              Log.d(TAG, String.valueOf(gps.getLongitude()));
  
              Geocoder myLocation = new Geocoder(HomeActivity.this);
  
              try
              {
                  myList = myLocation.getFromLocation(gps.getLatitude(), gps.getLongitude(), 1);
              }
              catch (Exception e)
              {
                  Log.d(TAG, "unable");
  
                  e.printStackTrace();
              }
              if(myList != null) {
                  try {
                      String country = myList.get(0).getCountryName();
                      Log.d(TAG, country);
                      findCountryInArrayList(country);
  
                  }
                  catch (Exception e)
                  {
                      Toast.makeText(HomeActivity.this, "Didn't manage to automatically detect location.", Toast.LENGTH_SHORT).show();
                      e.printStackTrace();
                  }
  
              }
  
          }
      });
  
  
  }
  </code></pre>
  
  <p>I want that immediately after the view is clicked the progressbar will become visible. However, it donesn't become visable until all the code is finished, which is against the whole point. 
  WHy is this not happening right at the beginning of the click? I have put progressBar.setVisibility(View.VISIBLE) at the top, why is it only executed after all the code is done, which sometimes takes a few seconds.</p>
  
  <p>Thanks very much.</p>