title: Loading multiple images to gridview android
body: <p>I have around 300 jpg images and I want to load this images to a grid view. I am following a <a href="http://javatechig.com/android/android-gridview-example-building-image-gallery-in-android" rel="nofollow">tutorial</a> </p>
  
  <p>But when I try to load images ( if its less than 25 its fine ) then I am getting outofmemory error.</p>
  
  <pre><code>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 &lt; imgs.length(); i++) {
              Bitmap bitmap = BitmapFactory.decodeResource(this.getResources(),
                      imgs.getResourceId(i, -1));
              imageItems.add(new ImageItem(bitmap, "Image#" + i));
          }
  
          return imageItems;
  
      }
  </code></pre>
  
  <p>This is the code to load the images and</p>
  
  <pre><code>customGridAdapter = new GridViewAdapter(this, R.layout.row_grid, getData());
          gridView.setAdapter(customGridAdapter);
  </code></pre>
  
  <p>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 ?</p>
  
  <p>Thanks</p>