android - Error: 'Spinner' does not contain a definiton for getSelectedItem'...' -
i need selected item off spinner getting above error , don't know why.
so, expecting spinner selected item without calling spinner's event handler, if that's possible, because need use on button click.
protected override void oncreate(bundle bundle) { base.oncreate(bundle); // set our view "main" layout resource setcontentview (resource.layout.main); button bt_ok = findviewbyid<button>(resource.id.bt_ok); spinner spinner = (spinner)findviewbyid<spinner>(resource.id.dd_spinner); // //getselecteditem not contain definition!!! // string spinner_text = spinner.getselecteditem().tostring(); // //do need this? // spinner.itemselected += new eventhandler<adapterview.itemselectedeventargs>(spinner_itemselected); var adapter = arrayadapter.createfromresource( this, resource.array.planet_array, global::android.resource.layout.simplespinneritem); adapter.setdropdownviewresource(global::android.resource.layout.simplespinnerdropdownitem); spinner.adapter = adapter; bt_ok.click += delegate { alertdialog.builder builder = new alertdialog.builder(this); builder.settitle("confirm"); // //i need value here!!! // builder.setmessage(new confirm().choice(spinner_text)); builder.setcancelable(true); builder.setpositivebutton("yes", delegate { }); builder.show(); }; }
the java getselecteditem
method in xamarin.android
transformed c# read-only property (selecteditem
):
var spinner = findviewbyid<spinner>(resource.id.dd_spinner); var selecteditem = spinner.selecteditem;
Comments
Post a Comment