My project is to display a slideshow of images from the selected folder.
I have done the project using ViewFlipper. The problem I am stuck at is memory issues when loading more images to the viewflipper. I get a force close error if the folder contains more than 15 images.
Bitmap mBitmap=BitmapFactory.decodeFile(ImageList.get(i));
image.setImageBitmap(mBitmap);
viewFlipper.addView(image);
System.gc();
}
viewFlipper.startFlipping();
How can this "out of memory" error be resolved, any other workarounds? I heard somewhere that we can use a single imageview and just change the image during runtime. Any pointers as to how do I begin? I also need to set the time-interval between image changes.
EDIT: Used ImageView instead of viewflipper and now I'm able to display a single image. How do I change the image in the Imageview after say 5 seconds? Code that I implemented in onCreate is:
ImageView imgView01 = (ImageView) findViewById(R.id.imageView1);
File dir = new File("/sdcard/WallpapersHD/");
File file[]=dir.listFiles();
for (int i=0;i<file.length;i++) {
Drawable d = (Drawable) Drawable.createFromPath(file[i].toString());
imgView01.setImageDrawable(d);