I am using a ViewFlipper to display images dynamically using array. The images are about 100. When I run that activity, the app stops with java.lang.OutOfMemoryError:
error. The combined image size is about 7 MB. What should be done in order to display all images? Following is java code I am using.
ViewFlipper viewflipper;
int result_images[]=
{R.drawable.resultone,R.drawable.resulttwo,R.drawable.resultthree,
...,R.drawable.resultonehundredsixteen};
viewflipper = (ViewFlipper) findViewById(R.id.viewflipper);
for(int i=0;i<result_images.length;i++)
{
// This will create dynamic image view and add them to ViewFlipper
setFlipperImage(result_images[i]);
}
viewflipper.startFlipping();
private void setFlipperImage(int res) {
Log.i("Set Filpper Called", res+"");
ImageView image = new ImageView(getApplicationContext());
image.setBackgroundResource(res);
viewflipper.addView(image);
}