How can you set the event listener for a Spinner when the selected item changes?
Basically what I am trying to do is something similar to this:
spinner1.onSelectionChange = handleSelectionChange;
void handleSelectionChange(Object sender){
//handle event
}
Some of the previous answers are not correct. They work for other widgets and views, but the documentation for the Spinner widget clearly states:
Better use OnItemSelectedListener() instead:
This works for me.
Note that onItemSelected method is also invoked when the view is being build, so you can consider putting it inside
onCreate()method call.