【发布时间】:2016-05-18 13:27:58
【问题描述】:
我的 WCF Web 服务上有这个:
public List<string> GetLocation()
{
InsertToFSRDataContext context = new InsertToFSRDataContext();
var loc = from z in context.Parameters where z.ParamGroup == "LOCATION" orderby z.ParamValue ascending select z.ParamDesc;
return loc.ToList<string>();
}
MainActivity.cs
protected override void OnCreate(Bundle bundle)
{
SetContentView(Resource.Layout.Main);
BasicHttpBinding binding = CreateBasicHttp();
_client = new FSRServiceClient(binding, EndPoint);
_client.GetLocationCompleted += ClientOnGetLocationCompleted;
_client.GetLocationAsync();
}
private void ClientOnGetLocationCompleted(object sender, GetLocationCompletedEventArgs getLocationCompletedEventArgs)
{
spinner1 = FindViewById<Spinner>(Resource.Id.spinner1);
List<string> list = new List<string>(getLocationCompletedEventArgs.Result);
ArrayAdapter<string> adapter1 = new ArrayAdapter<string>(this, Resource.Drawable.spinner_item, list);
spinner1.Adapter = adapter1;
}
在我的安卓模拟器上,它只显示微调器上的第一项。这可能是什么问题?
【问题讨论】:
-
从 WCF 发送时有多少项目?
-
@AnupSharma 仅 17 项,所以我不知道为什么它没有显示在微调器上
-
在函数
ClientOnGetLocationCompleted中,调试时你是否在第二行得到了所有17项? -
@AnupSharma 所以我再次运行该应用程序然后出现此错误:
Unhandled Exception: Java.Lang.ArrayIndexOutOfBoundsException: length=18; index=-1 -
出于某种原因,我可以很好地运行它,但只显示微调器上的第一项,但有时我会得到 java.lang 未处理的异常。
标签: c# android wcf xamarin spinner