简体   繁体   中英

Spinner only retrieving the first item from SQL Server database

I have this on my WCF web service:

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;
}

On my android emulator, it only shows the first item on the spinner. What could be the problem here?

我通过添加RunOnUiThread(()解决了这个问题,不知道可以很容易地解决它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM