Not able to execute loop based on thread.sleep
<p>I'm trying to display a series of images from a specific folder in sdcard - in the form of slideshow. <strong>filelist[]</strong> contains names of all files present in that directory.</p>

<p>I'm filtering out the images here. Next, thread.sleep(1000) does not seem to have any effect. Only the last image in the directory is displayed after a time of 1000ms. Where am I going wrong? Any other way I could accomplish this?</p>

<p>Maybe I've gone completely wrong. I'm a newbie so plz help.</p>

<pre><code>public class List_imgActivity extends Activity {
 /** Called when the activity is first created. */

Bitmap[] bitmapArray = new Bitmap[1000];

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Button pf=(Button) findViewById(R.id.pick_button);

    pf.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View v) {

            Intent intent = new Intent("org.openintents.action.PICK_DIRECTORY");

            intent.setData(Uri.parse("file:///sdcard"));
            intent.putExtra("org.openintents.extra.TITLE", "Please select a folder");
            intent.putExtra("org.openintents.extra.BUTTON_TEXT", "Use this folder");
            startActivityForResult(intent, 1);

        }

        });

    }
protected void onActivityResult(int requestCode, int recievecode, Intent intent)
{

    if (requestCode == 1 )

   {
      Uri uri = intent.getData();

      try {
        File f=new File(new URI(uri.toString()));
        final String nx=f.toString();

        if(f.isDirectory()) {

            File filelist[] = f.listFiles();




        for(int i=0;i&lt;filelist.length;i++) 
        {
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
        String filename = filelist[i].getName(); 
        int pos = filename.lastIndexOf(".");
        String ext = filename.substring(pos);


        if(ext.equals(".jpg"))
        {
            TextView tv1= (TextView) findViewById(R.id.textView1);
            tv1.setText(filelist[i].toString());


            ImageView iv1=(ImageView) findViewById(R.id.imageView1);





        bitmapArray[i] =  BitmapFactory.decodeFile(filelist[i].toString());

        iv1.setImageBitmap(bitmapArray[i]);


        }

        }


        }



    } catch (URISyntaxException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();

    }





   }

   } 

}
</code></pre>
