title: GridView Adapter on Monodorid
body: <p>I've been having a strange issue with a gridView which I populate from a list using a custom adapter.</p>
  
  <p>Everything looks normal until the first page of the gridView is full and then some of the subsequent items are either missing or out of sync.</p>
  
  <p>I've done two screen captures, the first with a single column, the second with two. As you can see, the first page is rendered correctly in both as pictured bellow:</p>
  
  <p>Single column: <a href="http://screencast.com/t/mSoEsDf1cY" rel="nofollow">http://screencast.com/t/mSoEsDf1cY</a></p>
  
  <p>and</p>
  
  <p>Two column: <a href="http://screencast.com/t/i6zfPLYf" rel="nofollow">http://screencast.com/t/i6zfPLYf</a></p>
  
  <p>I simplified the code to demonstrate the issue:</p>
  
  <pre><code>public class Activity1 : Activity
  {
      List&lt;Item&gt; _items = null;
  
      protected override void OnCreate (Bundle bundle)
      {
          base.OnCreate (bundle);
  
          // Set our view from the "main" layout resource
          SetContentView (Resource.Layout.Main);
  
          _items = new List&lt;Item&gt;();
  
          for ( int i =0; i &lt; 30; i++)
          {
              Item newItem = new Item();
              newItem.Text = "Item " + i;
              newItem.Bitmap = Android.Graphics.BitmapFactory.DecodeResource( this.Resources, Resource.Drawable.Icon );
  
              _items.Add( newItem );
          }
  
          GridView grid = FindViewById&lt;GridView&gt; (Resource.Id.gridView1);
          grid.SetNumColumns(2);
  
          ItemGridViewAdapter adapter = new ItemGridViewAdapter( this, _items);
          grid.Adapter = adapter;
      }
  
  }
  
  public class Item
  {
      public Android.Graphics.Bitmap Bitmap { get; set; }
      public string Text { get; set; }
  }
  
  public class ItemGridViewAdapter : BaseAdapter&lt;Item&gt;
  {
      private List&lt;Item&gt; _items = null;
      private Context _context = null;
  
      public override int Count {
          get {
              return _items.Count;
          }
      }
  
      public override long GetItemId (int position)
      {
          return position;
      }
  
      public override Item this[int position] {
          get {
              return _items[position];
          }
      }
  
      public ItemGridViewAdapter (Context context, List&lt;Item&gt; items)
      {
          _items = items;
          _context = context;
      }
  
      public override View GetView (int position, View convertView, ViewGroup parent)
      {
          //based on http://developer.android.com/guide/topics/ui/layout/gridview.html
  
          RelativeLayout layout = null;
  
          if (convertView == null) {
              layout = new RelativeLayout( _context );
  
              RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
  
              ImageView image = new ImageView (_context);
              image.LayoutParameters = new Gallery.LayoutParams (150, 150);
              image.SetImageBitmap ( this[position].Bitmap );
              image.Id = 1;
              layout.AddView (image);
  
              RelativeLayout.LayoutParams title_lp = new RelativeLayout.LayoutParams (RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.WrapContent);
              TextView title = new TextView (_context);
              title.Text = this[position].Text; 
              title.Id = 2;
              title.SetTextColor (Android.Graphics.Color.White);
              title_lp.AddRule (LayoutRules.RightOf, 1);
              title_lp.AddRule (LayoutRules.CenterVertical);
              layout.AddView (title, title_lp);
  
          } else {
  
              layout = (RelativeLayout)convertView;
          }
  
          return layout;
      }
  
  }
  </code></pre>
  
  <p>Any ideas  would be much appreciated.</p>