Xamarin控件使用之ListView

listview单列多行的显示,以后再加多列多行的实例。

 1 [Activity(Label = "GraphicAll", LaunchMode = LaunchMode.SingleTop)]
 2 public class GraphicMain : Activity//, IOnMenuTabClickListener
 3 {
 4 
 5 private ListView mListView;
 6 private List<string> items = new List<string>();
 7 
 8 string[] ItemName = { "投入产出", "成品率","能源日结" };
 9 protected override void OnCreate(Bundle savedInstanceState)
10 {
11 base.OnCreate(savedInstanceState);
12 
13 // Create your application here
14 SetContentView(Resource.Layout.GraphicAll);
15 
16 mListView = FindViewById<ListView>(Resource.Id.listVGraphiMain);
17 for (int i = 0; i < ItemName.Length; i++)
18 {
19 items.Add(ItemName[i]);
20 }
21 
22 ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, items);//多行一列的显示方法
23 mListView.Adapter = adapter;
24 mListView.ItemClick += mListView_ItemClick;//给没行添加点击事件
25 }
26 
27 void mListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
28 {
29 switch (e.Position)
30 {
31 case 0://
32 {
33 var intent = new Intent(this, typeof(InOutActivity));//
34 StartActivity(intent);
35 }
36 break;
37 case 1://
38 {
39 var intent1 = new Intent(this, typeof(productRateActivity));
40 StartActivity(intent1);
41 }
42 break;
43 case 2://
44 {
45 var intent = new Intent(this, typeof(DayEnegryActivity));
46 StartActivity(intent);
47 }
48 break;
49 
50 default:
51 new AlertDialog.Builder(this)
52 .SetMessage("该功能还在开发中...")
53 .Show();
54 break;
55 }
56 }
57 
58 }

 

转载于:https://www.cnblogs.com/longdb/p/6994861.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值