C# 具有多列的Android Listview
我正在尝试制作一个支持多列的C#Android Listview。 我在这里找到了一些如何创建Listview的代码: 但是,这是Java代码,因此我将其转换为C#,如下所示:C# 具有多列的Android Listview,c#,android,monodevelop,C#,Android,Monodevelop,我正在尝试制作一个支持多列的C#Android Listview。 我在这里找到了一些如何创建Listview的代码: 但是,这是Java代码,因此我将其转换为C#,如下所示: // List view control ListView list = (ListView) FindViewById(Resource.Id.mylist); List<Dictionary<string, string>> mylist =
// List view control
ListView list = (ListView) FindViewById(Resource.Id.mylist);
List<Dictionary<string, string>> mylist = new List<Dictionary<string, string>>();
Dictionary<string, string> map = new Dictionary<string, string>();
map.Add("Profit Centre", "Systems");
map.Add("Last Updated", "16/02/2012 15:34");
mylist.Add(map);
map = new Dictionary<string, string>();
map.Add("Profit Centre", "IDTS");
map.Add("Last Updated", "20/02/2012 10:26");
mylist.Add(map);
SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, Resource.Layout.list_item,new String[] {"Profit Centre", "Lasted Updated",}, new int[] { Resource.Id.columnA, Resource.Id.columnB});
list.Adapter = mSchedule;
//列表视图控件
ListView列表=(ListView)FindViewById(Resource.Id.mylist);
List mylist=新列表();
字典映射=新字典();
添加地图(“利润中心”、“系统”);
地图添加(“最近更新”,“2012年2月16日15:34”);
添加(地图);
map=新字典();
地图添加(“利润中心”、“IDT”);
地图添加(“最近更新”,“20/02/2012 10:26”);
添加(地图);
SimpleAdapter msSchedule=new SimpleAdapter(this,mylist,Resource.Layout.list_项,新字符串[]{“利润中心”,“持续更新”,},新int[]{Resource.Id.columnA,Resource.Id.columnB});
list.Adapter=mSchedule;
SimpleAdapter抱怨第二个参数不正确。它报告了这一点
错误1=
与“Android.Widget.simpledapter.simpledapter(Android.Content.Context,System.Collections.Generic.IList>,int,string[],int[])匹配的最佳重载方法具有一些无效参数
错误2=
参数2:无法从“System.Collections.Generic.List>”转换为“System.Collections.Generic.IList>”
为什么会这样?请您帮助我,因为我已经使用google进行了研究,看看是否有方法创建一个包含多个列的Listview(适用于Android),但在C#中找不到,只有Java代码
谢谢
Andrew Ashcroft似乎可以使用如下所述的CustomList适配器:
我修改了它,使它只有两列,利润中心和上次更新。似乎可以使用CustomList adapter,如下所述:
我修改了它,所以它只有两列,利润中心和上次更新。在Android
SimpleAdapter中,mylist的定义和预期列表之间存在不一致
将代码更改为以下内容
// List view control
ListView list = (ListView)FindViewById(Resource.Id.mylist);
IList<IDictionary<string, object>> mylist = new List<IDictionary<string, object>>();
IDictionary<string, object> map = new Dictionary<string, object>();
map.Add("Profit Centre", "Systems");
map.Add("Last Updated", "16/02/2012 15:34");
mylist.Add(map);
map = new Dictionary<string, object>()>;
map.Add("Profit Centre", "IDTS");
map.Add("Last Updated", "20/02/2012 10:26");
mylist.Add(map);
SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, Resource.Layout.list_item,new String[] {"Profit Centre", "Lasted Updated",}, new int[] { Resource.Id.columnA, Resource.Id.columnB});
ListAdapter = mSchedule;
与
问候,
Shalom Keynan在AndroidSimpleAdapter
将代码更改为以下内容
// List view control
ListView list = (ListView)FindViewById(Resource.Id.mylist);
IList<IDictionary<string, object>> mylist = new List<IDictionary<string, object>>();
IDictionary<string, object> map = new Dictionary<string, object>();
map.Add("Profit Centre", "Systems");
map.Add("Last Updated", "16/02/2012 15:34");
mylist.Add(map);
map = new Dictionary<string, object>()>;
map.Add("Profit Centre", "IDTS");
map.Add("Last Updated", "20/02/2012 10:26");
mylist.Add(map);
SimpleAdapter mSchedule = new SimpleAdapter(this, mylist, Resource.Layout.list_item,new String[] {"Profit Centre", "Lasted Updated",}, new int[] { Resource.Id.columnA, Resource.Id.columnB});
ListAdapter = mSchedule;
与
问候,
Shalom Keynan您是否使用c#进行android开发?是的,我使用MonoDevelop以c#进行android开发?您是否使用c#进行android开发?是的,我使用MonoDevelop以c#进行android开发
ListAdapter = mSchedule;