YellowsuN_A
Sunyelw
2017-09-06 08:29

C# android 无法转换类型

  • android
    Spinner state;
    TextView tvSp;
    ArrayAdapter<String> aas;

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        SetContentView(Resource.Layout.Main);

        state = FindViewById<Spinner>(Resource.Id.Sp);
        tvSp = FindViewById<TextView>(Resource.Id.tvSp);
        aas = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem);
        state.Adapter = aas;
        aas.Add(String.Empty);
        aas.Add("Alabam");
        aas.Add("China");
        aas.Add("American");
        aas.Add("California");

        state.ItemSelected += new EventHandler<ItemEventArgs>(sp_ItemSelected);
    }

    void sp_ItemSelected(object sender, ItemEventArgs e)
    {
        tvSp.Text = Convert.ToString(aas.GetItem(e.Position));
    }

然后报错:错误 2 无法将类型“System.EventHandler”隐式转换为“System.EventHandler”

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐

换一换