【发布时间】:2016-04-18 01:36:05
【问题描述】:
public class ListItemCollection<T> : IEnumerable<T>
where T : IHasLabel, IComparable<T>
{
错误: 错误 CS0703:可访问性不一致:约束类型 ....IHasLabel' 比 ....ListItemCollection' 更难访问(CS0703)
public override void OnActivityCreated(Bundle savedInstanceState)
{
base.OnActivityCreated(savedInstanceState);
/*
var items = new string[] { "Rock","Country", "Dance" };
lst = View.FindViewById<ListView> (Resource.Id.lstGenres);
lst.Adapter = new ArrayAdapter<string>(Activity, Resource.Layout.textViewItems,Resource.Id.textviewItems, items);
//lst = View.FindViewById<ListView> (Resource.Id.lst_genre);
//lst.SetAdapter(new ArrayAdapter<String>(this.Activity, Resource.Layout.GenerFragment, items));
lst.ItemClick+= delegate(object sender, AdapterView.ItemClickEventArgs e) {};*/
var data = new ListItemCollection<ListItemValue> () {
new ListItemValue ("Babbage"),
new ListItemValue ("Boole"),
new ListItemValue ("Berners-Lee"),
new ListItemValue ("Atanasoff"),
new ListItemValue ("Allen"),
new ListItemValue ("Cormack"),
new ListItemValue ("Cray"),
new ListItemValue ("Dijkstra"),
new ListItemValue ("Dix"),
new ListItemValue ("Dewey"),
new ListItemValue ("Erdos"),
};
var sortedContacts = data.GetSortedData ();
var adapter = CreateAdapter (sortedContacts);
ListAdapter = adapter;
}
SeparatedListAdapter CreateAdapter<T> (Dictionary<string, List<T>> sortedObjects)
where T : IHasLabel, IComparable<T>
{
var adapter = new SeparatedListAdapter (this);
foreach (var e in sortedObjects.OrderBy (de => de.Key)) {
var label = e.Key;
var section = e.Value;
adapter.AddSection (label, new ArrayAdapter<T> (this, Resource.Layout.lstGenres, section));
}
return adapter;
}
ListAdapter = adapter;-> 名称 listadapter 在当前上下文中不存在。
var adapter = new SeparatedListAdapter (this);-> 匹配 ....SeparatedListAdapter(android.content.context) 的最佳重载方法有一些无效参数
【问题讨论】: