错误表明我错过了使用指令或汇编参考,但我不是......

时间:2014-07-24 20:40:24

标签: c# android api xamarin

我非常擅长在解决方案中使用多个项目。我有两个项目: AutoPoster.Droid AutoPoster.Core

在AutoPoster.Droid中,我有一个引用AutoPoster.Core中的LocationInfo的适配器类。我现在收到此错误并且不确定原因:

类型或命名空间'核心'找不到(你错过了使用指令或组合引用吗?)

这是我的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using Android.App;
using Android.Views;
using Android.Widget;

namespace AutoPoster.Droid.Adapters
{
    public class PostInfoAdapter : BaseAdapter<Core.Model.LocationInfo>
    {
        private readonly Activity activity;
        public List<Core.Model.LocationInfo> LocationInformation { get; private set; } //Getting Error Here
        public PostInfoAdapter(Activity context, IEnumerable<Core.Model.LocationInfo> localInfo)//Getting Error Here
        {
            LocationInformation = new List<Core.Model.LocationInfo>(localInfo);//Getting Error Here
            activity = context;
        }

        public override int Count
        {
            get { return LocationInformation.Count; }
        }

        public override Core.Model.LocationInfo this[int position]//Getting Error Here
        {
            get { return LocationInformation[position]; }
        }

        public override long GetItemId(int position)
        {
            return position;
        }

        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            var view = convertView ?? activity.LayoutInflater.Inflate(Android.Resource.Layout.SimpleListItem2, null);

            var localInfo = LocationInformation[position];

            var name = view.FindViewById<TextView>(Android.Resource.Id.Text1);
            name.Text = !String.IsNullOrEmpty(localInfo.FullName) ? localInfo.FullName : localInfo.ShortName;

            var rxcui = view.FindViewById<TextView>(Android.Resource.Id.Text2);
            rxcui.Text = !String.IsNullOrEmpty(localInfo.FullName) ? localInfo.ShortName : String.Empty;

            return view;
        }

        public void ReloadData(IEnumerable<Core.Model.LocationInfo> locationInformation)//Getting Error Here
        {
            LocationInformation.Clear();
            LocationInformation.AddRange(locationInformation);
            NotifyDataSetChanged();
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您不能使用这样的命名空间。您无法在AutoPoster之后指定命名空间的一部分。您需要using的{​​{1}}指令:

AutoPoster.Core.Model

或者您需要完全限定类名:

using AutoPoster.Core.Model;

namespace AutoPoster.Droid.Adapters
{
    public class PostInfoAdapter : BaseAdapter<LocationInfo>
    {
        ...
    } 
}

编辑:是的,你确实需要从一个项目到另一个项目的引用......