Databinding a ListView with Mono for Android: Listing 2

Processing the Twitter request.

void ProcessRestJsonLINQHttpResponse(IAsyncResult iar)
	System.Collections.Generic.List<Tweet> twt = new System.Collections.Generic.List<Tweet>();
        HttpWebRequest request = (HttpWebRequest)iar.AsyncState;
        HttpWebResponse response;
        response = (HttpWebResponse)request.EndGetResponse(iar);
        System.IO.StreamReader strm = new System.IO.StreamReader(

		var jsResults = System.Json.JsonArray.Load(strm)["results"];
		for(int i = 0; i < jsResults.Count; i++)
			twt.Add(new Tweet(){ Status = jsResults[i]["text"].ToString(),
				StatusDate = jsResults[i]["created_at"].ToString(),
				StatusId = jsResults[i]["id"].ToString(),
				ProfileImage = jsResults[i]["profile_image_url"].ToString().Replace("\"", String.Empty) });

        //this.RunOnUiThread(() => {tv.Text = Convert.ToString("records: " + twt.Count.ToString();}));
        Android.Util.Log.Debug("http response", "finished");

        //Find the listview reference
        var listView = FindViewById<ListView>(Resource.Id.listView);

        //Create our adapter
        this.RunOnUiThread(() =>
            listAdapter = new CustomListAdapter(this, twt);

            //Hook up our adapter to our ListView
            listView.Adapter = listAdapter;
        //Wire up the click event
		listView.ItemClick += HandleItemClick;
    catch (System.Exception sysExc)
        Android.Util.Log.Error("http response", "Exception: " + sysExc.Message);

About the Author

Wallace (Wally) B. McClure has authored books on iPhone programming with Mono/Monotouch, Android programming with Mono for Android, application architecture, ADO.NET, SQL Server and AJAX. He's a Microsoft MVP, an ASPInsider and a partner at Scalable Development Inc. He maintains a blog, and can be followed on Twitter.

comments powered by Disqus


  • .NET for Apache Spark Debuts in Version 1.0

    The open source project .NET for Apache Spark has debuted in version 1.0, finally vaulting the C# and F# programming languages into Big Data first-class citizenship.

  • In-App Reviews Come to Xamarin.Forms Android

    Android is playing a little catch-up to iOS regarding in-app review functionality, just now coming tp Microsoft's Xamarin.Forms implementation.

  • C# Slides in Usage Ranking of Programming Languages

    "The fact that C# lost three places in the ranking of language communities during the last three years is mostly explained by its slower growth compared to C/C++ and PHP."

  • Telerik UI for Blazor Updated

    Progress announced an update to its Telerik UI for Blazor components, targeting Microsoft's open source Blazor framework that lets C# coders create web apps without having to rely upon JavaScript.

  • Infragistics Unveils UI Components for Blazor

    Infragistics, specializing in third-party UI/UX controls and tools, unveiled a new offering targeting Blazor, Microsoft's red-hot open source framework that allows for C#-based web development instead of traditional mainstay JavaScript.

Upcoming Events