title: Java Android Spinner onItemSelected
body: <p>The problem Im having is with the onItemSelected method. Whenever I try to change a Views value, Example: <code>TextView</code>, <code>EditView</code> it throws an error. </p>
  
  <p>What Im trying to do is get the when I click on something on the spinner it will display something on the text (anything currently). I hope you can help! Thanks. </p>
  
  <p>Here is my code so you can look at it:</p>
  
  <pre><code>public class MainActivity extends Activity implements OnItemSelectedListener {
  
      Spinner spinner;
      String[] paths = {"Rectangle", "Circle", "Triangle"};
      String selected;
      Button equals;
      TextView parm1, parm2;
      EditText value1, value2;
      CheckBox checkArea, checkPerm;
      Boolean checkedArea = true, checkedPerm = false;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(MainActivity.this, android.R.layout.simple_spinner_item, paths);
          spinner = (Spinner) findViewById(R.id.spinner);
          spinner.setAdapter(adapter);
          spinner.setOnItemSelectedListener(this);
      }
  
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
              long arg3) {
          int index = arg0.getSelectedItemPosition();
  
          if(paths[index] == "Rectangle"){
              //Does work
              Toast.makeText(getBaseContext(), "You selected Rectangle", Toast.LENGTH_LONG).show();
  
              //Doesn't work
              parm1.setText("Hello");
          }
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          // TODO Auto-generated method stub
  
      }
  }
  </code></pre>
  
  <p>Here is the error that pops up when I run the program. The virtual device will run the program all the way up to when i open it, then it will say Unfortunately *"Programs_name"* has stopped working. Here is the error log:</p>
  
  <pre><code> 02-12 17:26:41.395: D/dalvikvm(1478): GC_FOR_ALLOC freed 45K, 4% free 3331K/3444K, paused 47ms, total 51ms
  02-12 17:26:41.985: D/AndroidRuntime(1478): Shutting down VM
  02-12 17:26:41.985: W/dalvikvm(1478): threadid=1: thread exiting with uncaught exception (group=0xb1aadba8)
  02-12 17:26:41.995: E/AndroidRuntime(1478): FATAL EXCEPTION: main
  02-12 17:26:41.995: E/AndroidRuntime(1478): Process: com.example.gcfcalculator, PID: 1478
  02-12 17:26:41.995: E/AndroidRuntime(1478): java.lang.NullPointerException
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at com.example.gcfcalculator.MainActivity.onItemSelected(MainActivity.java:53)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at android.widget.AdapterView.fireOnSelected(AdapterView.java:893)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at android.widget.AdapterView.access$200(AdapterView.java:48)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:861)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at android.os.Handler.handleCallback(Handler.java:733)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at android.os.Handler.dispatchMessage(Handler.java:95)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at android.os.Looper.loop(Looper.java:136)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at android.app.ActivityThread.main(ActivityThread.java:5017)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at java.lang.reflect.Method.invokeNative(Native Method)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at java.lang.reflect.Method.invoke(Method.java:515)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  02-12 17:26:41.995: E/AndroidRuntime(1478):     at dalvik.system.NativeStart.main(Native Method)
  02-12 17:26:47.055: I/Process(1478): Sending signal. PID: 1478 SIG: 9
  </code></pre>