using Android.App;
using Android.Widget;
using Android.OS;
using System.Collections.Generic;
using Android.Runtime;
namespace App12
{
[Activity(Label = "App12", MainLauncher = true)]
public class MainActivity : Activity
{
ListView list_member;
SimpleAdapter content;
IList<IDictionary<string, object>> data;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
list_member = FindViewById<ListView>(Resource.Id.listView1);
//填充数据
FillDate();
//创建数据适配器
content = new SimpleAdapter(
this,
data,
Android.Resource.Layout.SimpleListItem2,
new string[] { "title", "number" },
new int[] { Android.Resource.Id.Text1,Android.Resource.Id.Text2 });
//把数据绑定到list_member 这个listview上
list_member.Adapter = content;
}
public void FillDate()
{
data = new List<IDictionary<string, object>>();
for (int i = 3; i < 20; i )
{
//我这里面的数据是写死的,有数据库的同学可以连数据库
JavaDictionary<string, object> achievement = new JavaDictionary<string, object>();
achievement.Add("title", "你好,我是张" i);
achievement.Add("number","座号" i);
data.Add(achievement);
}
}
}
}