Skip to content

Instantly share code, notes, and snippets.

@beginor
Forked from androidcn/gist:5520805
Last active December 17, 2015 00:59
Show Gist options
  • Save beginor/5525460 to your computer and use it in GitHub Desktop.
Save beginor/5525460 to your computer and use it in GitHub Desktop.
public class TableViewSource<TEntity> : UITableViewSource
{
private IList<TEntity> _data;
public TableViewSource(IEnumerable<TEntity> data) {
this._data = data.ToList ();
}
public override int RowsInSection (UITableView tableview, int section)
{
return this._data.Count;
}
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
var cellIdentifier = GetCellIdentitfier(typeof(TEntity));
var cellView = tableView.DequeueReusableCell(cellIdentifier);
// bind data to cell view;
return cellView;
}
// Get cell identifer for Entity type
string GetCellIdentitfier (Type type)
{
switch (type) {
case type1:
return "type1-cell-identifier";
case type2:
return "type2-cell-identifier";
}
return "";
}
}
@brouse36
Copy link

brouse36 commented May 6, 2013

Ive seen that on the iphone i had before

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment