title: Android ViewPager + GridView with images taking too much HEAP Memory
body: <p>I'm trying to make a Level selector to my game, now it's working but, it's really slow on some phones and some times not working (FC), I realized that it's using too much heap memory.</p>
  
  <p>I'm quite new on android dev, so here's my code, I hope you can help me.</p>
  
  <p><strong>ACTIVITY WITH THE VIEWPAGER:</strong></p>
  
  <pre><code>   setContentView(R.layout.level_selector);
     ViewPagerAdapter adapter = new ViewPagerAdapter(this);
     ViewPager myPager = (ViewPager) findViewById(R.id.mypagerwontwork); //cool id huh
     myPager.setAdapter(adapter);
     myPager.setCurrentItem(0);
  </code></pre>
  
  <p><strong>VIEW PAGER ADAPTER:</strong></p>
  
  <pre><code>  public Object instantiateItem(View collection, int position) {
         LayoutInflater inflater = (LayoutInflater)    activity.getSystemService(activity.LAYOUT_INFLATER_SERVICE);
       if(position == 0)
       {
           View layout = inflater.inflate(R.layout.world1, null);
           final GridView gridview = (GridView) layout.findViewById(R.id.gridLvl);
           gridview.setAdapter(new LevelAdapter(activity,"World1"));
           gridview.setOnItemClickListener(itemClickListener);
           ((ViewPager) collection).addView(layout); 
           return layout;
       }
  </code></pre>
  
  <p><strong>GRID VIEW ADAPTER:</strong></p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
          ImageView imageView = new ImageView(mContext);
          imageView.setLayoutParams(new GridView.LayoutParams(100, 100));
          if (mWorld.equals("World1"))
          {
              imageView.setImageResource(World1[position]);
          }
  </code></pre>
  
  <p><strong>USEFUL INFORMATION:</strong></p>
  
  <ul>
  <li>There are 3 "Worlds" (View page) each with a different background</li>
  <li>Each "World" has 15 Images, with number from 1 to 15.</li>
  <li>The image size is: +- 12kb</li>
  <li>The BG size is: +- 140kb </li>
  </ul>
  
  <p>I hope it's clear.</p>
  
  <p>thanks.</p>