title: Set default selection for a spinner
body: <p>I know this is probably a relativity simple question, but I seem to be overlooking the answer.</p>
  
  <p>In my app, I have a spinner for the user to select the state that they live in.  Currently, the app will be focusing on a local audience so I would like to set the default selection to be the state that they live in.</p>
  
  <p>I tried doing:</p>
  
  <p><strong>registration_screen.xml</strong></p>
  
  <pre><code>&lt;Spinner
      android:id="@+id/spinHomeState"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_column="1"
      android:entries="@array/state_list"
      android:prompt="@string/state_prompt"
      android:spinnerMode="dialog"/&gt;
  </code></pre>
  
  <p><strong>RegistrationScreen.java</strong></p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.registration_screen);
  
      Spinner HomeStateSpinner = (Spinner) findViewById(R.id.spinHomeState);
      HomeStateSpinner.setSelection('9');
  }
  </code></pre>
  
  <p>But the app crashes with the following logcat logs:</p>
  
  <blockquote>
    <p>06-03 13:52:44.512<br>
    1736-1736/com.name.of.app E/AndroidRuntime﹕
    FATAL EXCEPTION: main
        Process: com.hollywoodcert.soupserver.hollywoodcert, PID: 1736
        java.lang.IndexOutOfBoundsException: Invalid index 57, size is 50
                at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
                at java.util.Arrays$ArrayList.get(Arrays.java:66)
                at android.widget.ArrayAdapter.getItem(ArrayAdapter.java:337)
                at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:390)
                at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
                at android.widget.Spinner.makeView(Spinner.java:592)
                at android.widget.Spinner.layout(Spinner.java:540)
                at android.widget.Spinner.onLayout(Spinner.java:502)
                at android.view.View.layout(View.java:14817)
                at android.view.ViewGroup.layout(ViewGroup.java:4631)
                at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                at android.widget.LinearLayout.layoutHorizontal(LinearLayout.java:1660)
                at android.widget.TableRow.onLayout(TableRow.java:123)
                at android.view.View.layout(View.java:14817)
                at android.view.ViewGroup.layout(ViewGroup.java:4631)
                at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                at android.widget.TableLayout.onLayout(TableLayout.java:448)
                at android.view.View.layout(View.java:14817)
                at android.view.ViewGroup.layout(ViewGroup.java:4631)
                at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                at android.widget.ScrollView.onLayout(ScrollView.java:1468)
                at android.view.View.layout(View.java:14817)
                at android.view.ViewGroup.layout(ViewGroup.java:4631)
                at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                at android.view.View.layout(View.java:14817)
                at android.view.ViewGroup.layout(ViewGroup.java:4631)
                at android.support.v7.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:493)
                at android.view.View.layout(View.java:14817)
                at android.view.ViewGroup.layout(ViewGroup.java:4631)
                at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                at android.view.View.layout(View.java:14817)
                at android.view.ViewGroup.layout(ViewGroup.java:4631)
                at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
                at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
                at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
                at android.view.View.layout(View.java:14817)
                at android.view.ViewGroup.layout(ViewGroup.java:4631)
                at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
                at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
                at android.view.View.layout(View.java:14817)
                at android.view.ViewGroup.layout(ViewGroup.java:4631)
                at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
                at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
                at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
                at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
                at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
                at android.view.Choreographer.doCallbacks(Choreographer.java:574)
                at android.view.Choreographer.doFrame(Choreographer.java:544)
                at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
                at android.os.Handler.handleCallback(Handler.java:733)
                at android.os.Handler.dispatchMessage(Handler.java:95)
                at android.os.Looper.loop(Looper.java:136)
                at android.app.ActivityThread.main(ActivityThread.java:5017)
                at java.lang.reflect.Method.invokeNative(Native Method)
                at java.lang.reflect.Method.invoke(Method.java:515)
                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
                at dalvik.system.NativeStart.main(Native Method)</p>
  </blockquote>
  
  <p>I would appreciate any advice.</p>