【问题标题】:Labelled Sections xamarin android that it don't run on xamarin android new version标记部分 xamarin android 它不在 xamarin android 新版本上运行
【发布时间】: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) 的最佳重载方法有一些无效参数

【问题讨论】:

    标签: xamarin xamarin.android


    【解决方案1】:

    刚查了一下,有人忘了加public...

    namespace TablesAndCellStyles
    {
        interface IHasLabel
        {
            string Label {get;}
        }
    }
    

    不太清楚您的问题是什么,请使用您自己的 IHasLabel 界面。

    【讨论】:

    • 在我添加 public 并显示 6 个错误之后。我会更新代码
    猜你喜欢
    • 1970-01-01
    • 2022-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-24
    • 2017-09-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多