title: How to refresh an imageView inside an adapter for a GridView
body: <p>I've been fooling around with Android but I'm stuck. I have a adapter class that 
  sets an image in an imageview for each item in my gridView. I use the observer pattern to notify the activity that calls the update method and it refreshes the adapter with notifydatasetchanged and that invalidates the gridview itself and the imageView. </p>
  
  <p>The problem is that when i change an object (which has a reference to a drawable), and try to update, nothing happens in the imageview. I've tried to debug and the objects are changed so i don't understand why it doesn't update...</p>
  
  <p>Also, with this it works perfect to make the images disappear, so that's pretty akward..: shape.setImage(android.R.color.transparent) </p>
  
  <pre><code>@Override
      public void update(Observable arg0, Object arg1)
      {
      //  Toast.makeText(this, "I am notified",0).show();
  
          adapter.notifyDataSetChanged();
          gridView.findViewById(R.id.picture).invalidate();
          gridView.invalidate();
  
      }
  </code></pre>
  
  <p>This is an example of an object that needs to be showed:</p>
  
  <pre><code>public class Square extends Shape
  {
      public Square()
      {
          setImage(R.drawable.square);
      }
      public String print()
      {
          return "s ";
      }
      public String getName()
      {
          return "Square";
      }
  }
  </code></pre>
  
  <p>my adapter:</p>
  
  <pre><code>public class GridAdapter extends ArrayAdapter&lt;Shape&gt;
  {
       Context context;
       int layoutResourceId;   
       List&lt;Shape&gt; data = null;
  
  
  
      public GridAdapter(Context context, int layoutResourceId, List&lt;Shape&gt; data)
       {
              super(context, layoutResourceId, data);
              this.layoutResourceId = layoutResourceId;
              this.context = context;
              this.data = data;
       }
       public View getView(int position, View convertView,ViewGroup parent) 
       {
              LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
              View rowView = inflater.inflate(R.layout.list_item, parent, false);
  
              rowView.setBackgroundResource(R.drawable.customshape);
  
              ImageView imgView =(ImageView)rowView.findViewById(R.id.picture);
  
              imgView.setImageResource(data.get(position).getImage());
  
              return rowView;
       }
  </code></pre>