0
非同期Webサービス呼び出し後に表示するリストビューを取得しようとしていますが、何らかの理由でこのコードが失敗しています....今、アプリがクラッシュするだけです。MonoDroid非同期Webサービスの呼び出し
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Test.MyWeb;
namespace Test
{
[Activity(Label = "Favorites")]
public class FavoritesActivity : ListActivity
{
private ProgressDialog d;
private TextView tv;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
d = new ProgressDialog(this);
d.SetTitle("Loading...");
d.SetMessage("Please wait...");
d.SetIcon(Resource.Drawable.chef_icon);
d.Show();
Test.MyWeb.Daedalus Service = new Daedalus();
Service.getCategoriesCompleted += Service_OnComplete;
Service.getCategories();
}
private void Service_OnComplete(object s, getCategoriesCompletedEventArgs e)
{
try
{
d.Hide();
List<Test.MyWeb.CATEGORY> Categories = e.Result.ToList();
List<string> cats = new List<string>();
foreach (Test.MyWeb.CATEGORY Item in Categories)
{
cats.Add(Item.NAME);
}
ListAdapter = new ArrayAdapter<string>(this, Resource.Layout.Favorites, cats);
ListView.TextFilterEnabled = true;
ListView.ItemClick += delegate(object sender, ItemEventArgs args)
{
// When clicked, show a toast with the TextView text
Toast.MakeText(Application, ((TextView)args.View).Text, ToastLength.Short).
Show();
};
} catch(Exception ex)
{
Toast.MakeText(this, ex.Message, ToastLength.Short).Show();
}
}
}
}