Code example for Spinner

Methods: getItemAtPosition

0
		spinCalendar.setAdapter(spinnerArrayAdapter);
		spinCalendar.setOnItemSelectedListener(new OnItemSelectedListener() {
 
			@Override 
			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;
				else 
					// select it 
					selectedCalendar = iselect.intValue();
			} 
 
			@Override 
			public void onNothingSelected(AdapterView<?> arg0) {
				// set to invalid id 
				selectedCalendar = -1;
			}