title: android: populate a spinner from strings.xml
body: <p>I'm having a problem with populating my spinner with days of the week.</p>
  
  <p>layout xml:</p>
  
  <pre><code>&lt;Spinner 
      android:id="@+id/week_spinner"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:drawSelectorOnTop="true"/&gt;
  </code></pre>
  
  <p>strings.xml</p>
  
  <pre><code>&lt;resources&gt;
    &lt;string-array name="days_of_week"&gt;
      &lt;item&gt;Monday&lt;/item&gt;
      &lt;item&gt;Tuesday&lt;/item&gt;
      &lt;item&gt;Wednesday&lt;/item&gt;
      &lt;item&gt;Thursday&lt;/item&gt;
      &lt;item&gt;Friday&lt;/item&gt;
    &lt;/string-array&gt;
  &lt;/resources&gt;
  </code></pre>
  
  <p>java:</p>
  
  <pre><code>public class AddModule extends Activity {
      Spinner day;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          day = (Spinner)findViewById(R.id.week_spinner);
  
          ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this, R.array.days_of_week, android.R.layout.simple_spinner_item);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          day.setAdapter(adapter);
          setContentView(R.layout.activity_add_module);
      }
  }
  </code></pre>
  
  <p>It's the setAdapter line that's causing the app to crash. I'm getting the following errors</p>
  
  <pre><code>11-05 21:24:31.235: W/dalvikvm(867): threadid=1: thread exiting with uncaught exception (group=0x40a9a228) 
  11-05 21:24:31.245: E/AndroidRuntime(867): FATAL EXCEPTION: main 
  11-05 21:24:31.245: E/AndroidRuntime(867): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cathal.timetable/com.cathal.timetable.AddModule}: java.lang.NullPointerException 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2202) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2237) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.access$600(ActivityThread.java:139) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1262) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.os.Handler.dispatchMessage(Handler.java:99) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.os.Looper.loop(Looper.java:154) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.main(ActivityThread.java:4974) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at java.lang.reflect.Method.invokeNative(Native Method) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at java.lang.reflect.Method.invoke(Method.java:511) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at dalvik.system.NativeStart.main(Native Method) 11-05 21:24:31.245: E/AndroidRuntime(867): Caused by: java.lang.NullPointerException 11-05 21:24:31.245: E/AndroidRuntime(867):    at com.cathal.timetable.AddModule.onCreate(AddModule.java:18) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.Activity.performCreate(Activity.java:4538) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1071) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2158) 
  11-05 21:24:31.245: E/AndroidRuntime(867):  ... 11 more
  </code></pre>
  
  <p>This was working fine yesterday. I can't figure out if I maybe changed something or if I have an eclipse problem.</p>