title: Android Spinner dynamically change items
body: <p>I want to use a Spinner in my App. The context (items) of the Spinner are depending on the user preferences done in the Settings of the App.</p>
  
  <p>I created the Spinner with no items. After loading the App the Spinner has one Entry. To get the Entries the User has to go to the menu and load an image. Based on this the items are loaded into a String Array. This String Array will be hand over to a Adapter. See Code: </p>
  
  <pre><code>List&lt;String&gt; als = new ArrayList&lt;String&gt;();
  als = Arrays.asList(Data.getfloornames());
  adapter = new ArrayAdapter&lt;String&gt;(this, R.array.flooritem, als);
  adapter.notifyDataSetChanged();
  floornum.setAdapter(adapter);
  </code></pre>
  
  <p>After this is done. The user will be returned to the menu settings. Clicking in the menu Settings the return button of the devices, result an abort of the app.</p>
  
  <pre><code>Error from Logcat is FATAL Exception: main.
  05-16 15:12:43.193: E/AndroidRuntime(9128): android.content.res.Resources$NotFoundException: Resource ID #0x7f060002
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.content.res.Resources.getValue(Resources.java:1014)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.content.res.Resources.loadXmlResourceParser(Resources.java:2139)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.content.res.Resources.getLayout(Resources.java:853)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:371)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:193)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.Spinner.onMeasure(Spinner.java:439)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.View.measure(View.java:15518)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.View.measure(View.java:15518)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:681)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.View.measure(View.java:15518)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.View.measure(View.java:15518)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.View.measure(View.java:15518)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.View.measure(View.java:15518)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4825)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.View.measure(View.java:15518)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.Choreographer.doFrame(Choreographer.java:532)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.os.Handler.handleCallback(Handler.java:725)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.os.Handler.dispatchMessage(Handler.java:92)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.os.Looper.loop(Looper.java:137)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at android.app.ActivityThread.main(ActivityThread.java:5041)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at java.lang.reflect.Method.invokeNative(Native Method)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at java.lang.reflect.Method.invoke(Method.java:511)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  05-16 15:12:43.193: E/AndroidRuntime(9128):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>What am I doing wrong? Is it not possible to set the Spinner Items in the menu settings of the app?</p>