title: Handler does not delay - Android Studio Java
body: <p>I am working on a project. My program shows a video by videoview and get values from an excel file. I am having difficulty in showing the values one by one. I am trying to use some delay methods. I have used Thread.sleep and SystemClock.sleep methods but they freeze the entire app and phone. Now I am trying to use handler method. I don't receive any error but there is no delay. I am putting my code below.</p>
  <p>If anyone can help me with this delay, I will be very happy.</p>
  <pre><code>package com.example.exceldeneme;
  
  import androidx.appcompat.app.AppCompatActivity;
  import android.net.Uri;
  import android.os.Bundle;
  import android.os.Handler;
  import android.os.Looper;
  import android.widget.MediaController;
  import android.widget.VideoView;
  import android.os.SystemClock;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.TextView;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.nio.charset.Charset;
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.lang.String;
  import java.util.Random;
  import java.util.concurrent.TimeUnit;
  import java.util.List;
  
  
  public class MainActivity&lt;number_cars&gt; extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          VideoView videoView = findViewById(R.id.video_view);
          Button  button = findViewById(R.id.button);
          TextView text_cars = findViewById(R.id.textEmpty);
          TextView text_total_lots = findViewById(R.id.textTotalLots);
          readData();
          int number_of_park = 100;
          text_total_lots.setText(String.valueOf(number_of_park));
          int counter = 0;
  
          String videoPath = &quot;android.resource://&quot; + getPackageName() + &quot;/&quot; + R.raw.camera_out;
          Uri uri = Uri.parse(videoPath);
          videoView.setVideoURI(uri);
          MediaController mediaController = new MediaController(this);
          videoView.setMediaController(mediaController);
          mediaController.setAnchorView(videoView);
          
          for (String i : number_of_cars.get(0)){
              counter = counter + 1 ;
          }
  
          button.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  int counter = 0;
                  for (String i : number_of_cars.get(0)){
                      counter = counter + 1 ;
                  }
                  for (int i = 1; i &lt; counter-1;i= i +1){
                      String count_park = number_of_cars.get(0)[i];
                      new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
                          @Override
                          public void run() {
                              text_cars.setText(count_park);
                          }
                      }, 1000);
  
  
                      //SystemClock.sleep(1000); //ms
                      Log.d(&quot;Selam&quot;,&quot;SORUN YOK&quot;);
                  }
              }
          });
  
  
      }
  
  
      private ArrayList&lt;String[]&gt; number_of_cars = new ArrayList&lt;String[]&gt;();
      private void readData() {
          InputStream is = getResources().openRawResource(R.raw.numberofcars);
          BufferedReader reader = new BufferedReader(
                  new InputStreamReader(is, Charset.forName(&quot;UTF-8&quot;))
          );
          String line = &quot;&quot;;
              try {
                  while(((line = reader.readLine()) != null)) {
                  String[] tokens = line.split(&quot;,&quot;);
                                  number_of_cars.add(tokens);
                  Log.d(&quot;MyActivity&quot;,&quot;Just created&quot;+ Arrays.toString(tokens));
                  }
              }
              catch (IOException e) {
                  Log.wtf(&quot;MyActivity&quot;,&quot;Error reading data file on line&quot; + line, e);
                  e.printStackTrace();
              }
      }
  }
  </code></pre>