title: Custom ListAdapter to display a List<> inside a ListFragment
body: <p>So I am pretty new at developing for android and I decided to go with Xamarin as I like C# and I learned it first.</p>
  
  <p>My actual problem surfaced 2 days ago, I have this app for which I created several fragments that display from click events listeners and such, it is a very basic app. I created a List&lt;> that I want to use for my items in this ListFragment. I created the custom adapter like any other custom adapter I created before:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  using Android.App;
  using Android.Content;
  using Android.OS;
  using Android.Runtime;
  using Android.Views;
  using Android.Widget;
  using MSApp.Droid.ListClasses;
  
  namespace MSApp.Droid
  {
      public class CountryAdapter : BaseAdapter
      {
          public List&lt;Country&gt; countryList { get; set; }
          Context context;
  
          public CountryAdapter(Context context)
          {
              this.context = context;
              countryList = new List&lt;Country&gt;();
          }
  
          public override int Count
          {
              get
              {
                  return countryList.Count;
              }
          }
  
          public override View GetView(int position, View convertView, ViewGroup parent)
          {
              View row = null;
              if (convertView == null)
              {
                  LayoutInflater inflater = (LayoutInflater)context.GetSystemService(Context.LayoutInflaterService);
                  row = inflater.Inflate(MSApp.Droid.Resource.Layout.CountryRow, parent, false);
              }
              else
              {
                  row = convertView;
              }
              var countryLabel = row.FindViewById&lt;TextView&gt;(MSApp.Droid.Resource.Id.countryTextView);
              var countryImage = row.FindViewById&lt;ImageView&gt;(MSApp.Droid.Resource.Id.flagImageView);
  
              var data = countryList[position];
  
              countryLabel.Text = data.name;
              countryImage.SetImageResource(data.imageID);
  
              return row;
          }
  
          public override Java.Lang.Object GetItem(int position)
          {
              return null;
          }
  
          public override long GetItemId(int position)
          {
              return countryList[position].id;
          }
      }
  }
  </code></pre>
  
  <p>But when I try to create the ListFragment I cant seem to get it working together. I got something like this:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  
  using Android.App;
  using Android.Content;
  using Android.OS;
  using Android.Runtime;
  using Android.Util;
  using Android.Views;
  using Android.Widget;
  using MSApp.Droid.ListClasses;
  
  namespace MSApp.Droid.Fragments
  {
      public class CountryFragment : Android.Support.V4.App.ListFragment
      {
          private List&lt;Country&gt; countryList { get; set; }
          private CountryAdapter countryAdapter { get; set; }
          public override void OnCreate(Bundle savedInstanceState)
          {
              base.OnCreate(savedInstanceState);
  
              // Create your fragment here
              countryList = new List&lt;Country&gt;();
              countryList.Add(new Country() { name = "Peru", imageID = MSApp.Droid.Resource.Drawable.Peru });
              countryAdapter = new CountryAdapter(this);
          }
  
          public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
          {
              // Use this to return your custom view for this Fragment
              // return inflater.Inflate(Resource.Layout.YourFragment, container, false);
  
              return base.OnCreateView(inflater, container, savedInstanceState);
          }
  </code></pre>
  
  <p>And that is where I get the problem, I cannot set the context to a fragment it says and I cant move forward with it, I have been looking everywhere on the internet, youtube, here, courses online, but nothing seems to use this kind of thing anywhere. If there is someone who can give me a hand with pointing me in the right direction it would be greatly appreciated.</p>
  
  <p>Thank you in advance!</p>