I have around 300 jpg images and I want to load this images to a grid view. I am following a tutorial
But when I try to load images ( if its less than 25 its fine ) then I am getting outofmemory error.
private ArrayList getData() {
final ArrayList imageItems = new ArrayList();
// retrieve String drawable array
TypedArray imgs = getResources().obtainTypedArray(R.array.image_ids);
for (int i = 0; i < imgs.length(); i++) {
Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(),
imgs.getResourceId(i, -1));
imageItems.add(new ImageItem(bitmap, "Image#" + i));
}
return imageItems;
}
This is the code to load the images and
customGridAdapter = new GridViewAdapter(this, R.layout.row_grid, getData());
gridView.setAdapter(customGridAdapter);
This is the code to set the images. Do you guys have any idea how I can load all my ( 200+ images ) to my grid view ?
Thanks