title: Using Spinner selection as a value in Android
body: <p>I am trying to get a Spinner to work in Android. It displays fine and I can select any one of the options in the list. But how do I transfer that to a string?
  I would have thought in the code below that 'selected' would hold the selected string, but I get an 'Illegal modifier for the local class YourItemSelectedListener; only abstract or final is permitted' error on the 'YourItemSelectedListener'.
  What am I doing wrong?
  Many thanks for any help.</p>
  
  <pre><code>Spinner spinnerFPS = (Spinner) findViewById(R.id.sp_FPS);
          ArrayAdapter adapter = ArrayAdapter.createFromResource(
                  this, R.array.framesps, android.R.layout.simple_spinner_item);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          spinnerFPS.setAdapter(adapter);
          spinnerFPS.setOnItemSelectedListener(new YourItemSelectedListener());
  
  
          public class YourItemSelectedListener implements OnItemSelectedListener {
  
              public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) {
                  String selected = parent.getItemAtPosition(pos).toString();
              }
  
              public void onNothingSelected(AdapterView parent) {
                  // Do nothing.
              }
          }
  </code></pre>