title: NullPointerException: Attempt to invoke virtual method ... on a null object reference
body: <p>When I start my SettingsActivity, I get the following Error, but I don't know why, because I have done everything as always.</p>
  
  <p>ERROR:</p>
  
  <p><code>FATAL EXCEPTION: main                                                                                  Process: com.android.niklasvlach.vertretung, PID: 9175
                                                                                    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.niklasvlach.vertretung/com.android.niklasvlach.vertretung.SettingsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setOnItemSelectedListener(android.widget.AdapterView$OnItemSelectedListener)' on a null object reference                                                                                  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2358)                                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420)                                                                                      at android.app.ActivityThread.access$900(ActivityThread.java:154)                                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)                                                                                      at android.os.Handler.dispatchMessage(Handler.java:102)                                                                                    at android.os.Looper.loop(Looper.java:135)                                                                                     at android.app.ActivityThread.main(ActivityThread.java:5294)                                                                                      at java.lang.reflect.Method.invoke(Native Method)                                                                                      at java.lang.reflect.Method.invoke(Method.java:372)                                                                                      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)                                                                                   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Spinner.setOnItemSelectedListener(android.widget.AdapterView$OnItemSelectedListener)' on a null object reference                                                                                    at com.android.niklasvlach.vertretung.SettingsActivity.onCreate(SettingsActivity.java:28)                                                                                  at android.app.Activity.performCreate(Activity.java:5990)                                                                               at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)                                                                                at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)                                                                            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2420)                                                                              at android.app.ActivityThread.access$900(ActivityThread.java:154)                                                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1321)                                                                                  at android.os.Handler.dispatchMessage(Handler.java:102)                                                                                 at android.os.Looper.loop(Looper.java:135)                                                                                 at android.app.ActivityThread.main(ActivityThread.java:5294)                                                                               at java.lang.reflect.Method.invoke(Native Method)                                                                                at java.lang.reflect.Method.invoke(Method.java:372)                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:904)                                                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) </code></p>
  
  <p>The Code:</p>
  
  <pre><code>public class SettingsActivity extends AppCompatActivity {
  
  Spinner select;
  EditText username;
  EditText password;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  
      select = (Spinner) findViewById(R.id.selectclass);
      username = (EditText) findViewById(R.id.username_view);
      password = (EditText) findViewById(R.id.password_view);
  
      select.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
  
          public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int pos, long text) {
              Toast.makeText(SettingsActivity.this,"" + text,Toast.LENGTH_LONG).show();
  
          }
  
          public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
  
          }
      });
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_settings);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>If anything else is needed, I will post it!</p>