title: ViewHolder GridView laggy
body: <p>I´m using the first time <code>ViewHolder</code> with <code>GridView</code> and i´m new to android/java
  It´s working a lot of better then with <code>ImageView</code>.</p>
  
  <p>But the biggest problem i have is that scrolling is laggy.
  I have two questions:</p>
  
  <p>First one: What can I do to make performance better?
  Second one: Can I use and how can I use <code>BitmapWorkerTask</code>/<code>AsyncTask</code> with it?</p>
  
  <p>What I tried was <code>android:scrollingCache="false"</code> as everybody is writting but it seems that performance is a little bit better for me with <code>android:scrollingCache="true"</code>.</p>
  
  <p>Code:</p>
  
  <p><strong>Layout</strong></p>
  
  <pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
                    android:orientation="vertical"  
                    android:layout_width="fill_parent"  
                    android:layout_height="fill_parent"  
                    android:padding="10dp"&gt;  
      &lt;ImageView android:id="@+id/ic_launcher"
      android:contentDescription="@string/desc"  
      android:layout_width="match_parent" 
      android:layout_height="match_parent"
      android:columnWidth="90dp"
      android:numColumns="4"
      android:verticalSpacing="10dp"
      android:horizontalSpacing="10dp"
      android:stretchMode="columnWidth"
      android:gravity="center"
      android:fastScrollEnabled="true"
      android:persistentDrawingCache="scrolling"
      android:scrollingCache="true"
      android:animationCache="false"
      android:smoothScrollbar="true"
      /&gt; 
  
      &lt;/LinearLayout&gt; 
  </code></pre>
  
  <p><strong>ImageAdapter</strong></p>
  
  <pre><code>import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.GridView;
  import android.widget.ImageView;
  
  
  
  public class ImageAdapter extends BaseAdapter {
      private Context mContext;
      private LayoutInflater mInflater; 
  
  
      // Keep all Images in array about 600
      public Integer[] mThumbIds = {
  
  };
  // Constructor
      public ImageAdapter(Context c) {   
          mInflater = LayoutInflater.from(c);  
             mContext = c;
      }
  
      @Override
      public int getCount() {
          return mThumbIds.length;
      }
  
      @Override
      public Object getItem(int position) {
          return mThumbIds[position];
      }
  
      @Override
      public long getItemId(int position) {
          return 0;
      }
  
  
  
   // create a new ImageView for each item referenced by the     
      public View getView(int position, View convertView, ViewGroup parent) {     
       ViewHolder holder;
         if (convertView == null) {  // if it's not recycled,     
               convertView = mInflater.inflate(R.layout.categorycontent, null);  
             convertView.setLayoutParams(new GridView.LayoutParams(130, 130));  
            holder = new ViewHolder();  
               holder.icon = (ImageView )convertView.findViewById(R.id.ic_launcher);  
               convertView.setTag(holder);  
           } else {  
               holder = (ViewHolder) convertView.getTag();
  
           }  
  holder.icon.setAdjustViewBounds(true);  
  holder.icon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);     
  holder.icon.setImageResource(mThumbIds[position]);  
  return convertView;     
      }     
      class ViewHolder {  
          ImageView icon;  
      }  }
  </code></pre>
  
  <p>I hope you dudes have some ideas for me :)</p>
  
  <p><strong>NewCodewithErrors</strong></p>
  
  <pre><code>    }
  
      class ViewHolder {  
          ImageView icon;  
      } 
  
   // create a new ImageView for each item referenced by the     
      public View getView(int position, View convertView, ViewGroup parent) {     
       ViewHolder holder;
         if (convertView == null) {  // if it's not recycled,     
               convertView = mInflater.inflate(R.layout.categorycontent, null);  
             convertView.setLayoutParams(new GridView.LayoutParams(130, 130));  
            holder = new ViewHolder();  
               holder.icon = (ImageView )convertView.findViewById(R.id.ic_launcher);  
               convertView.setTag(holder);  
           } else {  
               holder = (ViewHolder) convertView.getTag();
  
           }  
  holder.icon.setAdjustViewBounds(true);  
  holder.icon.setScaleType(ImageView.ScaleType.CENTER_INSIDE);     
  holder.icon.setImageResource(mThumbIds[position]);
  
  //Here i have the errors:
  //The constructor ImageAdapter.LoadImage() is undefine ImageAdapter.java
  //The method execute(Integer...) in the type AsyncTask&lt;Integer,Void,Bitmap&gt; is not 
  //applicable for the arguments (View) ImageAdapter.java
  
  new LoadImage().execute(convertView);
  
  return convertView;     
      }   
  
  
      private class LoadImage extends AsyncTask&lt;Integer, Void, Bitmap&gt; {
  
          private ImageView imv;
  
          public LoadImage(ImageView imv) {
              this.imv = imv;
          }
  
          @Override
          protected void onPostExecute(Bitmap result) {
  
              if (result != null &amp;&amp; imv != null) {
                  imv.setVisibility(View.VISIBLE);
                  imv.setImageBitmap(result);
              } else {
                  imv.setVisibility(View.GONE);
              }
          }
  
          @Override
          protected Bitmap doInBackground(Integer... params) {
              Bitmap bitmap = null;
              bitmap = BitmapFactory.decodeResource(mContext.getResources(),
                      params[0]);
              return bitmap;
          }
  
      }}
  </code></pre>