title: Populate a ListView from a Json file in C#
body: <p>I am working with Xamarin and C# to create some basic Android application.
  I am in the learning process.</p>
  
  <p>What I am trying to do is to populate a ListView with some data extract from a JSON file. 
  I have made two methods, one async task to call the server and one for parsing and extract the data (<a href="http://mysafeinfo.com/api/data?list=englishmonarchs&amp;format=json" rel="nofollow noreferrer">http://mysafeinfo.com/api/data?list=englishmonarchs&amp;format=json</a>). </p>
  
  <p>My problem now is that I don't have any idea how to feed the listview with this data. </p>
  
  <p>Thank you for your time. </p>
  
  <pre><code>namespace App4 
  {
  [Activity(Label = "App4", MainLauncher = true, Icon = "@drawable/icon")]
  public class MainActivity : Activity
  {
      //Declare a Cancellation Token Source 
      CancellationTokenSource cts;
  
      Button startbutton;
      Button stopbutton;
      TextView textView0;
      ListView listView;
  
      protected override void OnCreate(Bundle bundle)
      {
          base.OnCreate(bundle);
          SetContentView(Resource.Layout.Main);
  
          startbutton = FindViewById&lt;Button&gt;
              (Resource.Id.startbutton);
          stopbutton = FindViewById&lt;Button&gt;
              (Resource.Id.stopbutton);
          textView0 = FindViewById&lt;TextView&gt;
              (Resource.Id.textView0);
          listView = FindViewById&lt;ListView&gt;
              (Resource.Id.listView);
  
  
          //BASIC ASYNC START TASK
          // click the startbutton to start the process
          startbutton.Click += async (sender, e) =&gt;
          {                
              // Instantiate the CancellationTokenSource
              cts = new CancellationTokenSource();
  
              try
              {
                  // **** GET ****
                 await Task.Run(() =&gt; LoadDataAsync(cts.Token));
  
              }
              catch (TaskCanceledException)
              {
                  textView0.Text = " Download deleted ";
              }
              catch (Exception)
              {
                  textView0.Text = "Generic Error";
              }
  
              // ***Set the CancellationTokenSource to null when the download is complete.
              cts = null;
          };
  
          //STOP BUTTON 
          stopbutton.Click += (sender, e) =&gt;
          {
              if (cts != null)
              {
                  cts.Cancel();
              }
          };
      }
  
      //THIS METHOD LOAD JSON DATA FROM AN URL AND RETURN A STRING
  
      public static async Task&lt;string&gt; LoadDataAsync(CancellationToken ct)
      {
          // Call the server and take the file
          var client = new HttpClient();
          client.MaxResponseContentBufferSize = 1024 * 1024; //read up to 1MB of data
  
          await Task.Delay(250);//Delay the task for deleting purpose
  
          var response = await client.GetAsync(new Uri("http://mysafeinfo.com/api/data?list=englishmonarchs&amp;format=json"), ct);
          var result = await response.Content.ReadAsStringAsync();
  
          return result;
  
      }
  
      //THIS METHOD GET THE JSON DATA FROM THE STRING 
  
      private static void GetData(string result)
      {
  
          // Parse the Json file.
          JArray file = JArray.Parse(result);
  
          foreach (var item in file.Children&lt;JObject&gt;())
          {               
              string name = (string)item.SelectToken("nm");
              string city = (string)item.SelectToken("cty");
              string house = (string)item.SelectToken("hse");
              string years = (string)item.SelectToken("yrs");
          }
      }
  
  }
  </code></pre>
  
  <p>}</p>