title: Spinner Causes App Crash
body: <p>I'm new with Stackoverflow and also programming with Android</p>
  
  <p>I've done this code in my AndroidApp:</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
  private Spinner spinner;
  private LinkedList&lt;Integer&gt; list;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      if (savedInstanceState == null) {
          getSupportFragmentManager().beginTransaction()
                  .add(R.id.container, new PlaceholderFragment())
                  .commit();
      }
  
      this.ageSpinner();
  
  
  }
  
  private void ageSpinner(){
  
      list = new LinkedList&lt;Integer&gt;();
      spinner = (Spinner) this.findViewById(R.id.spinner1);
  
      for(Integer i=0; i&lt;=4; i++){
  
  
          list.add(i);
  
      }
  
      ArrayAdapter&lt;Integer&gt; spinnerAdapter = new ArrayAdapter&lt;Integer&gt;(this, android.R.layout.simple_spinner_item, list);
      spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  
      spinner.setAdapter(spinnerAdapter);
  
  }
  </code></pre>
  
  <p>And my logCat throws me a <code>NullPointerException</code>.</p>
  
  <p>I've tried to do this code changing the Linkelist to ArrayList, String Array, but my app crash.</p>