title: Populating and updating a ListView in Xamarin
body: <p>I just want to populate a ListView in Xamarin with data and update it, so that the items get visible. Now I searched a lot and tried this:</p>
  
  <pre><code>    List&lt;string&gt; items = new List&lt;string&gt; ();
      ArrayAdapter ListAdapter = null;
  
      protected override void OnCreate(Bundle bundle)
      {
          base.OnCreate(bundle);
  
          SetContentView(Resource.Layout.Main);
  
          Button button = FindViewById&lt;Button&gt;(Resource.Id.MyButton);
          ListView listView = FindViewById&lt;ListView&gt;(Resource.Id.listView1);
  
          ListAdapter = new ArrayAdapter&lt;String&gt;(this, Android.Resource.Layout.SimpleListItem1, items);
          listView.Adapter = ListAdapter;
  
          button.Click += delegate { Server(listView); };
      }
  </code></pre>
  
  <p>Now the method 'Server' has following code:</p>
  
  <pre><code> items.Add("The server is running at port localEndPoint...");                
   ListAdapter.NotifyDataSetChanged();
  </code></pre>
  
  <p>This does absolutely nothing. Nothing gets updated. I also tried:        </p>
  
  <pre><code> RunOnUiThread(() =&gt;
   {
     ListAdapter.NotifyDataSetChanged();
   });
  </code></pre>
  
  <p>but here it does not even jump into the RunOnUiThread.</p>
  
  <p>What am I doing wrong? I'm very new to Xamarin. </p>
  
  <p>UPDATE: Full Server Code:</p>
  
  <pre><code>  try
          {
              IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
              IPAddress ipAddress = ipHostInfo.AddressList[0];
              IPEndPoint localEndPoint = new IPEndPoint(ipAddress, 11000);
  
              /* Initializes the Listener */
              TcpListener myList = new TcpListener(ipAddress, 8001);
  
              /* Start Listeneting at the specified port */
              myList.Start();
  
              ListAdapter.Add("The server is running at port localEndPoint...");
              RunOnUiThread(() =&gt;
              {
                  ListAdapter.NotifyDataSetChanged();
              });
  
              Console.WriteLine("The local End point is  :" +
                                myList.LocalEndpoint);
              Console.WriteLine("Waiting for a connection.....");
  
              Socket s = myList.AcceptSocket();
              Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
  
              byte[] b = new byte[100];
              int k = s.Receive(b);
              Console.WriteLine("Recieved...");
              for (int i = 0; i &lt; k; i++)
                  Console.Write(Convert.ToChar(b[i]));
  
              ASCIIEncoding asen = new ASCIIEncoding();
              s.Send(asen.GetBytes("The string was recieved by the server."));
              Console.WriteLine("\nSent Acknowledgement");
              /* clean up */
              s.Close();
              myList.Stop();
  
          }
          catch (Exception e)
          {
              Console.WriteLine("Error..... " + e.StackTrace);
          }
  </code></pre>