topical media & game development
#mobile-application-12-DerbyNames-MonoTouch-DerbyNames-MonoTouch-VixensController.cs / cs
using System;
using System.Drawing;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Collections.Generic;
namespace DerbyNames_MonoTouch
{
public partial class VixensController : UIViewController
{
public VixensController () : base ("VixensController", null)
{
Title = NSBundle.MainBundle.LocalizedString ("Vixens", "Vixens");
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
UITableView tableView;
string teamName = "Lansing Derby Vixens";
List<DerbyName> fullRosterData = Network.GetRoster(teamName);
List<string> data = new List<string>();
fullRosterData.ForEach(derbyName => data.Add(derbyName.Name));
tableView = new UITableView();
tableView.DataSource = new TableViewDataSource(data);
tableView.Frame = new RectangleF (0, 0, this.View.Frame.Width,this.View.Frame.Height);
this.View.AddSubview(tableView);
}
public override void ViewDidUnload ()
{
base.ViewDidUnload ();
ReleaseDesignerOutlets ();
}
private class TableViewDataSource : UITableViewDataSource
{
static NSString kCellIdentifier = new NSString ("DerbyName");
private List<string> list;
public TableViewDataSource (List<string> list)
{
this.list = list;
}
public override int RowsInSection (UITableView tableview, int section)
{
return list.Count;
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell (kCellIdentifier);
if (cell == null)
{
cell = new UITableViewCell (
UITableViewCellStyle.Default,
kCellIdentifier);
}
cell.TextLabel.Text = list[indexPath.Row];
return cell;
}
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.