title: Android Spinner throws an exception
body: <p>I have an activity that contains a TextView, a ListView and a Spinner.
  The spinner contains 4 items. onCreate, the spinner is assigned with one of the values that matches the current activity.
  When user clicks on another Item a new Intent must be started (a new activity with the same layout).
  However, I get an error when I leave uncommented the code regarding the spinner.
  My Activity works fine without the "implements OnItemSelectedListener" and the implementation of the event.</p>
  
  <p>So my code for the spinner :</p>
  
  <pre><code>public class ViziteIeri extends Activity implements OnItemSelectedListener{
  ...
  
  protected void onCreate(Bundle icicle) {
          super.onCreate(icicle);
          setContentView(R.layout.my_new_screen);
                  Spinner spinner = (Spinner) findViewById(R.id.spinner1);
          ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this,
                  R.array.liste_array, android.R.layout.simple_spinner_item);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          spinner.setAdapter(adapter);
                  spinner.setOnItemSelectedListener(this);
  }
  
  @Override
      public void onItemSelected(AdapterView&lt;?&gt; parent, View view, 
              int pos, long id) {
          // An item was selected. You can retrieve the selected item using
          // parent.getItemAtPosition(pos)
  
          Toast toast1 = Toast.makeText(getApplicationContext(),""+parent.getItemAtPosition(pos), Toast.LENGTH_SHORT);
          toast1.show();
  
          Intent i = null;
          if(parent.getItemIdAtPosition(pos) == 1) {
              i=new Intent(ViziteIeri.this, ViziteAzi.class);
          }
          if(parent.getItemIdAtPosition(pos) == 2) {
              i=new Intent(ViziteIeri.this, ViziteMaine.class);
          }
          if(parent.getItemIdAtPosition(pos) == 3) {
              i=new Intent(ViziteIeri.this, ViziteViitor.class);
          }
          startActivity(i);           
  
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          // TODO Auto-generated method stub
  
      }
  }
  </code></pre>
  
  <p>So what am I doing wrong?
  Sorry for the previous code. I changed the name of the activity just for pasting reasons. Now they are fixed. In my real app, of course the activities are properly named, otherwise I could not run the app (right?)</p>
  
  <p>@CodeMonkey - here is the error log:  </p>
  
  <pre><code>`07-29 23:56:56.155: D/AndroidRuntime(2474): Shutting down VM
  07-29 23:56:56.155: W/dalvikvm(2474): threadid=1: thread exiting with uncaught exception (group=0x40015560)
  07-29 23:56:56.174: E/AndroidRuntime(2474): FATAL EXCEPTION: main
  07-29 23:56:56.174: E/AndroidRuntime(2474): java.lang.NullPointerException
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1374)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.app.Activity.startActivityForResult(Activity.java:2827)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.app.Activity.startActivity(Activity.java:2933)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at com.softwarex.mydualscreenpro.ViziteIeri.onItemSelected(ViziteIeri.java:89)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.widget.AdapterView.fireOnSelected(AdapterView.java:871)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.widget.AdapterView.access$200(AdapterView.java:42)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:837)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.os.Handler.handleCallback(Handler.java:587)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.os.Handler.dispatchMessage(Handler.java:92)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.os.Looper.loop(Looper.java:123)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at android.app.ActivityThread.main(ActivityThread.java:3683)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at java.lang.reflect.Method.invokeNative(Native Method)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at java.lang.reflect.Method.invoke(Method.java:507)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  07-29 23:56:56.174: E/AndroidRuntime(2474):     at dalvik.system.NativeStart.main(Native Method)`
  </code></pre>
  
  <p>I changed back the activity name because it became confusing. So the activity name is "ViziteIeri"
  And again... if I let the event assignment uncommented, I cannot run the activity without receiving the above error stack</p>