I have created a Spinner successfully which contains the Items: Hello1, Hello2 and Hello3.
Now I try to create an "OnItemSelectedListener" event so when one click on an item, I try to catch this item in the "spinnerItemClick" event.
(I have a custom adapter but the problem would be focused on the: OnItemSelectedListener)
But for the below line, I get this error. So I am not sure how to set this up as I try below?
spinner.OnItemSelectedListener = spinnerItemClick;
Complete code:
void createSpinner()
{
Android.Content.Context context = ApplicationContext;
Spinner spinner = new Spinner(context);
spinner.Clickable = true;
spinner.OnItemSelectedListener = spinnerItemClick;
Adapter1 adapter1; List<String> list1 = new List<String>(); list1.Add("Hello1"); list1.Add("Hello2"); list1.Add("Hello3");
adapter1 = new Adapter1(this, Android.Resource.Layout.SimpleListItem1, list1, this, "1");
spinner.Adapter = adapter1;
}
void spinnerItemClick(object sender, AdapterView.IOnItemClickListener e)
{
//Here how to get the item that is clicked?
}
I have tried to do the below code also but as seen my compiler underlines alot of things in red. So I am not sure why this is happening:
(The easisest is to show an image here I think)
Spinner does not contains a defintion for 'setOnItemSelectedListener' and no extension method 'setOnItemSelectedListener' accepting a first argument of type 'Spinner' could be found (are you missing a using directive or an assembly reference.
Name name '@Override' does not exist in the current context