Spinner 仅从 SQL 服务器数据库中检索第一项
Spinner only retrieving the first item from SQL Server database
我的 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;
}
在我的 android 模拟器上,它只在微调器上显示第一项。这可能是什么问题?
我通过添加 RunOnUiThread(()
解决了这个问题。没想到这么容易就解决了
我的 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;
}
在我的 android 模拟器上,它只在微调器上显示第一项。这可能是什么问题?
我通过添加 RunOnUiThread(()
解决了这个问题。没想到这么容易就解决了