Mono Touch Table应用
来源:互联网 发布:log4j打印sql语句 编辑:程序博客网 时间:2024/06/11 10:12
using System;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
namespace BasicTable
{
public class Application
{
public static void Main (string[] args)
{
try
{
UIApplication.Main (args, null, "AppDelegate");
}
catch (Exception e)
{
Console.WriteLine (e.ToString ());
}
}
}
[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate
{
protected UIWindow window;
protected HomeScreen iPhoneHome;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.MakeKeyAndVisible ();
iPhoneHome = new HomeScreen();
iPhoneHome.View.Frame = new System.Drawing.RectangleF(0
, UIApplication.SharedApplication.StatusBarFrame.Height
, UIScreen.MainScreen.ApplicationFrame.Width
, UIScreen.MainScreen.ApplicationFrame.Height);
window.AddSubview (iPhoneHome.View);
return true;
}
}
}
using System;
using System.Drawing;
using System.Collections.Generic;
using MonoTouch.UIKit;
namespace BasicTable
{
public class HomeScreen : UIViewController
{
public HomeScreen ()
{
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
UITableView table = new UITableView (View.Bounds); //defaults to Plain style
table.AutoresizingMask = UIViewAutoresizing.All;
string[] tableItems = new string[] { "Vegetables", "Fruits", "Flower Buds", "Legumes", "Bulbs", "Tubers" };
table.Source = new TableSource (tableItems);
this.View.Add (table);
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace BasicTable
{
public class TableSource : UITableViewSource
{
protected string[] tableItems;
protected string cellIdentifier = "TableCell";
public TableSource (string[] items)
{
tableItems = items;
}
/// <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.Length;
}
/// <summary>
/// Called when a row is touched
/// </summary>
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
new UIAlertView ("Row Selected",
tableItems [indexPath.Row], null, "OK", null).Show ();
tableView.DeselectRow (indexPath, true);
// bool ch = tableView.VisibleCells [indexPath.Row].Accessory == UITableViewCellAccessory.Checkmark;
// if (ch) {
// tableView.VisibleCells [indexPath.Row].Accessory = UITableViewCellAccessory.DisclosureIndicator;
// } else {
// tableView.VisibleCells [indexPath.Row].Accessory = UITableViewCellAccessory.Checkmark;
// }
}
// public override void AccessoryButtonTapped (UITableView tableView, NSIndexPath indexPath)
// {
// new UIAlertView ("DetailDisclosureButton Touched"
// , tableItems [indexPath.Row], null, "OK", null).Show ();
// }
/// <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
UITableViewCell cell = tableView.DequeueReusableCell (cellIdentifier);
// if there are no cells to reuse, create a new one
if (cell == null)
cell = new UITableViewCell (UITableViewCellStyle.Subtitle, cellIdentifier);
if (indexPath.Row == 0) {
cell.ImageView.Image = UIImage.FromFile ("Images/Icons/50_icon.png");
}
cell.TextLabel.Text = tableItems [indexPath.Row];
cell.Accessory = UITableViewCellAccessory.DisclosureIndicator;
cell.DetailTextLabel.Text = "kkkk";
return cell;
}
//...
}
}
效果图如下:
- Mono Touch Table应用
- mono touch:Customizing a Table's Appearance
- mono touch中,Async/Await 关键词应用举例
- mono touch登录设计
- Mono Touch文件下载
- mono touch:Displaying Images
- mono touch :Displaying Alerts
- mono touch: Appearance API
- mono touch隐藏键盘
- mono touch 隐藏键盘
- mono touch中touch触发对象判断
- mono touch中自定义事件
- mono touch后端事件处理
- mono touch 中图片的StretchableImage属性
- mono touch中定器NSTimer,隐藏状态栏
- mono touch中UIProgressView的使用
- mono touch中UISwitch控件的使用
- mono touch中UISegmentedControl控件的使用
- javascript 秘密花园
- C#中的扩展方法
- 做平台网站建设需要注意的那些事
- 『转』区分Ruby的require,load,和include
- ubuntu忘记root密码 的解决方法
- Mono Touch Table应用
- 模块和组件的区别
- 逆向技巧 去Nag窗口
- Hadoop2.x:HDFS存储小文件问题及其解决方法
- centos 64 安装mysql5.5
- JavaSE_网络编程_TCP
- 判断checkbox选中的个数
- Linux Jobs等前后台运行命令解
- JAVA的包装类 【转】