Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.IO;
- using MonoTouch.Foundation;
- using MonoTouch.UIKit;
- namespace Tandlaegen {
- public class TableSource : UITableViewSource {
- List<TableItem> tableItems;
- NSString cellIdentifier = new NSString("TableCell");
- UIViewController viewController;
- public TableSource (UIViewController ctrl, List<TableItem> items)
- {
- tableItems = items;
- viewController = ctrl;
- }
- /// <summary>
- /// Called by the TableView to determine how many cells to create for that particular section.
- /// </summary>
- public override int RowsInSection (UITableView tableview, int section)
- {
- return tableItems.Count;
- }
- /// <summary>
- /// Called when a row is touched
- /// </summary>
- public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
- {
- Console.WriteLine ("\n");
- //new UIAlertView("Row Selected", tableItems[indexPath.Row].Heading, null, "OK", null).Show();
- tableView.DeselectRow (indexPath, true);
- Console.WriteLine ("Row Selected: " + tableItems [indexPath.Row].Heading.ToString());
- }
- /// <summary>
- /// Called by the TableView to get the actual UITableViewCell to render for the particular row
- /// </summary>
- public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
- {
- // request a recycled cell to save memory
- CustomCell cell = tableView.DequeueReusableCell (cellIdentifier) as CustomCell;
- cell.
- // if there are no cells to reuse, create a new one
- if (cell == null) {
- cell = new CustomCell (cellIdentifier);
- }
- cell.UpdateCell (tableItems[indexPath.Row].Heading
- , tableItems[indexPath.Row].SubHeading
- , UIImage.FromFile ("Images/" +tableItems[indexPath.Row].ImageName)
- , tableItems[indexPath.Row].Type);
- return cell;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement