title: Android: Gridview going blank while scrolling fast
body: <p>the GridView is going blank in android if i scroll very fastly</p>
  
  <p>please give me a solution for this..</p>
  
  <p>Thanks in advance..</p>
  
  <p>this is my code</p>
  
  <pre><code>gridView.setAdapter(new ImageAdapter(ChangedDashboard.this, stringarray));
  </code></pre>
  
  <p>this is my adapter class which is set on the gridview</p>
  
  <pre><code>public class ImageAdapter extends BaseAdapter {
  private Context context;
  private final String[] menuvalues;
  
  public ImageAdapter(Context context, String[] menuValues) {
      this.context = context;
      this.menuvalues = menuValues;
  }
  public View getView(int position, View convertView, ViewGroup parent) {
  
      LayoutInflater inflater = (LayoutInflater) context
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
      View gridView;
  
      if (convertView == null) {
  
          gridView = new View(context);
  
          // get layout from mobile.xml
          gridView = inflater.inflate(R.layout.changedashboard, null);
  
      } else {
          gridView = (View) convertView;
      }
  
      TextView textView = (TextView) gridView
      .findViewById(R.id.textView1);
      textView.setText(menuvalues[position]);
  
      // set image based on selected text
      ImageView imageView = (ImageView) gridView
      .findViewById(R.id.imageView1);
  
      String mobile = menuvalues[position];
  
      if (mobile.equals("1")) {
          imageView.setImageResource(R.drawable.new1);
      } else if (mobile.equals("2")) {
          imageView.setImageResource(R.drawable.new2);
      } else if (mobile.equals("3")) {
          imageView.setImageResource(R.drawable.new3);
      }else if (mobile.equals("4")) {
          imageView.setImageResource(R.drawable.new4);
      } else if (mobile.equals("5")) {
          imageView.setImageResource(R.drawable.new5);
      }else if (mobile.equals("6")) {
          imageView.setImageResource(R.drawable.new6);
      } 
  
      return gridView;
  }
  
  public int getCount() {
      return menuvalues.length;
  }
  
  public Object getItem(int position) {
      return null;
  }
  
  public long getItemId(int position) {
      return 0;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Please give me the solution for this</p>
  
  <p>Updated code </p>
  
  <pre><code>public class ImageAdapter extends BaseAdapter {
  private Context context;
  private final String[] menuvalues;
  
  public ImageAdapter(Context context, String[] menuValues) {
      this.context = context;
      this.menuvalues = menuValues;
  }
  public View getView(int position, View convertView, ViewGroup parent) {
  
      LayoutInflater inflater = (LayoutInflater) context
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
      View gridView;
  
      if (convertView == null) {
  
          gridView = new View(context);
  
          // get layout from mobile.xml
          gridView = inflater.inflate(R.layout.changedashboard, null);
          ViewHolder holder = new ViewHolder();
          holder.textView = (TextView) gridView
                  .findViewById(R.id.textView1);
          holder.imageView = (ImageView) gridView
                  .findViewById(R.id.imageView1);
          gridView.setTag(holder);
  
      } else {
          gridView = (View) convertView;
      }
  
      /*TextView textView = (TextView) gridView
      .findViewById(R.id.textView1);*/
  
  
      // set image based on selected text
      /*ImageView imageView = (ImageView) gridView
      .findViewById(R.id.imageView1);*/
  
      String mobile = menuvalues[position];
  
      ViewHolder holder = (ViewHolder)gridView.getTag();
      holder.textView.setText(mobile);
      if (mobile.equals("1")) {
          holder.imageView.setImageResource(R.drawable.new1);
      } else if (mobile.equals("2")) {
          holder.imageView.setImageResource(R.drawable.new2);
      } else if (mobile.equals("3")) {
          holder.imageView.setImageResource(R.drawable.new3);
      }else if (mobile.equals("4")) {
          holder.imageView.setImageResource(R.drawable.new4);
      } else if (mobile.equals("5")) {
          holder.imageView.setImageResource(R.drawable.new5);
      }
  
      return gridView;
  }
  
  public int getCount() {
      return menuvalues.length;
  }
  
  public Object getItem(int position) {
      return null;
  }
  
  public long getItemId(int position) {
      return 0;
  }
  public static class ViewHolder {
      TextView textView;
      ImageView imageView;
  }
  </code></pre>
  
  <p>}</p>