title: Android spinner with button and TOAST
body: <p>I am having a problem with my code that is supposed to display a toast when a button is clicked.</p>
  
  <pre><code>public TextView textView,textView2;
  
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      Spinner spinner = (Spinner) findViewById(R.id.spinner);
      Spinner spinner2 = (Spinner) findViewById(R.id.spinner2);
  
  
  }
  public void start(View view) {
  
      Context context = getApplicationContext();
      Toast.makeText(context, String.valueOf(spinner.getSelectedItemPosition()) , Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p>I do not know why the Toast message does not display and the program crashes when pressing the button. </p>
  
  <p>This is my spinner in <code>activity_main.xml</code></p>
  
  <pre><code>&lt;Spinner
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="73dp"
      android:id="@+id/spinner2"
      android:entries="@array/jednostki"/&gt;
  </code></pre>
  
  <p>button in xml</p>
  
  <pre><code>&lt;Button
      android:text="Start"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_above="@+id/spinner"
      android:layout_centerHorizontal="true"
      android:layout_marginBottom="71dp"
      android:id="@+id/button"
      android:onClick="start"/&gt;
  </code></pre>
  
  <p>and array with item </p>
  
  <pre><code>&lt;string-array name="jednostki"&gt;
      &lt;item&gt;Celsjusze&lt;/item&gt;
      &lt;item&gt;Farenheity&lt;/item&gt;
      &lt;item&gt;Kelwiny&lt;/item&gt;
  &lt;/string-array&gt;
  </code></pre>