Databinding a ListView with Mono for Android: Listing 3

Overriding GetView.

public override View GetView(int position, View convertView, ViewGroup parent)
{
    //Get our object for this position
    var item = items[position];

    var view = context.LayoutInflater.Inflate(Android.Resource.Layout.SimpleListItemChecked, null);

    try
    {
        var textTop = view.FindViewById(Android.Resource.Id.Text1) as TextView;
       textTop.Text = item.Status;
    }
    catch (System.Exception sysExc)
    {
        Android.Util.Log.Error("custom adapter", sysExc.Message);
    }
    //Finally return the view
    return view;
}

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

Featured

Subscribe on YouTube