title: Android - GridView forcing update on data change
body: <p>I've implemented this sample (2. Custom Adapter example)
  <a href="http://www.mkyong.com/android/android-gridview-example/" rel="nofollow">http://www.mkyong.com/android/android-gridview-example/</a>
  and it works.</p>
  
  <p>I then wanted to "refresh" the data with a new set, which didn't work until I did this:</p>
  
  <pre><code>imageAdapter.notifyDataSetChanged();
  </code></pre>
  
  <p>and then removed the following check in the ImageAdapter getView method :</p>
  
  <pre><code> if (convertView == null) {
  </code></pre>
  
  <p>Here is my current getView method</p>
  
  <pre><code>public View getView(int position, View convertView, ViewGroup parent) {
  
      LayoutInflater inflater = (LayoutInflater) context
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
      View gridView;
  
      // if (convertView == null) {  // stopped my GridView from updating !!
      if (true)
      {
          gridView = new View(context);
  
          // get layout from mobile.xml
          gridView = inflater.inflate(R.layout.mobile, null);
  
          // set value into textview
          TextView textView = (TextView) gridView
                  .findViewById(R.id.grid_item_label);
  
          textView.setText(mobileValues[position]);
  
  
          // set image based on selected text
          ImageView imageView = (ImageView) gridView
                  .findViewById(R.id.grid_item_image);
  
          imageView.setImageResource(R.drawable.square);
  
  
      } else {
          gridView = (View) convertView;
      }
  
      return gridView;
  }
  </code></pre>
  
  <p>I'm concerned it is now doing unnecessary processing over and over - i.e. inflating view multiple times?</p>
  
  <p>Should I be creating a new GridView every time this is called ?</p>