2 yellowsun a YellowsuN_A 于 2017.09.06 16:29 提问

C# 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个回答

caozhy
caozhy   Ds   Rxr 2017.09.06 20:54
已采纳

猜想,你引用了不正确的类库,或者.net 框架版本选择不对

YellowsuN_A
YellowsuN_A 恩恩 很有可能
2 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片