title: Android delay when refreshing ListView?
body: <p>The idea is simple. Create a new TextView, attach it to ListView and then start downloading contents from a server. When there is no content downloading, the ListView is instantly updated. But after adding the TextView to the ListView I started downloading, refreshing listView on screen is done after the downloading is finished. </p>
  
  <p>Main function</p>
  
  <pre><code>TextView startingDownloadingText = createTextView("Downloading started");
  linearLayout.addView(startingDownloadingText);
  boolean success = downloadFromUrl(stringUri, fileName, context);
  if (success) {......
  </code></pre>
  
  <p>Function for downloading</p>
  
  <pre><code>public boolean downloadFromUrl(String stringURL, String fileName, Context myContext) { 
  
      try {
          URL url = new URL(stringURL);             
          Resources res = myContext.getResources();
          String envDirectory = Environment.getExternalStorageDirectory().toString();
          String zipDirectory = envDirectory.concat(res.getString(R.string.zipDirectory));
  
          File fileDirectory = new File(zipDirectory);
          fileDirectory.mkdirs();
  
          ZipDownloader zipDownloader = new ZipDownloader(zipDirectory, fileName);
          AsyncTask&lt;URL, Void, Boolean&gt; asynZipDownloader = zipDownloader.execute(url);
          Boolean success = null;
          try {
              success = asynZipDownloader.get();
          } catch (InterruptedException e) {
              e.printStackTrace();
          } catch (ExecutionException e) {
              e.printStackTrace();
          }
          if (success){
              Log.d("DownloadFromUrl", "file ready");
              return true;
          }
          return false;
      } catch (IOException e) {
          Log.e("DownloadFromUrl", "Error: " + e);
          return false;
      }
  
  }
  </code></pre>
  
  <p>Why is this happening ?</p>
  
  <p>UPDATE</p>
  
  <p>AsyncTask&lt;...>.get() is UI blocking and using onPostExecute() in AsyncTask will do the work in non blocking way. Example : <a href="https://stackoverflow.com/questions/9963691/android-asynctask-sending-callbacks-to-ui">android asynctask sending callbacks to ui</a></p>