Code example for Spinner

Methods: getItemAtPosition

		spinCalendar.setOnItemSelectedListener(new OnItemSelectedListener() {
			public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
				String filter = spinCalendar.getItemAtPosition(arg2).toString();
				// get id for that string 
				Integer iselect = calendars.get(filter);
				// well, not in map (may not be needed) 
				if (iselect == null)
					selectedCalendar = -1;
					// select it 
					selectedCalendar = iselect.intValue();
			public void onNothingSelected(AdapterView<?> arg0) {
				// set to invalid id 
				selectedCalendar = -1;
Contextual code suggestions in your IDE  Get Codota for Java