Mysterious NullPointerException gets thrown when working with a Spinner
<p>I have a clickable TextView and a Spinner whose visibility is set to <code>GONE</code>.</p>

<p>This is my layout snippet:</p>

<pre><code>&lt;TextView
    android:id="@+id/strip1"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:text="  Order Name       ID      Description     Type" 
    android:textSize="15dip"
    android:textStyle="bold"
    android:clickable="true"
    android:gravity="left"
    android:textColor="#ffffff"
    android:layout_weight="1" /&gt;

&lt;Spinner android:id="@+id/sortSpinner"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:drawSelectorOnTop="true"
    android:visibility="gone"
    android:clickable="true"
    android:prompt="@string/prompt" /&gt;
</code></pre>

<p>In <code>onCreate</code> I have this:</p>

<pre><code>TextView strip = (TextView)findViewById(R.id.strip1);
strip.setOnClickListener(new OnClickListener() {

    public void onClick(View arg0) {
        spinner_show();
    }

});
</code></pre>

<p><code>spinner_show()</code> looks like this:</p>

<pre><code>private void spinner_show() {

    String str = new String[2];
    str[0] = "Ascending";
    str[1] = "Descending";

    Spinner sortSpin = (Spinner)findViewById(R.id.sortSpinner);
    ArrayAdapter&lt;String&gt; sizeArrayAdapter =
        new ArrayAdapter&lt;String&gt;(this,
                android.R.layout.simple_spinner_item, str);
    sizeArrayAdapter.setDropDownViewResource(
        android.R.layout.simple_spinner_dropdown_item);
    sortSpin.setAdapter(sizeArrayAdapter);
    sortSpin.setOnItemSelectedListener(
        new AdapterView.OnItemSelectedListener() {
            public void onItemSelected(AdapterView&lt;?&gt; parent,
                    View v, int pos, long id) {

        }

        public void onNothingSelected(AdapterView&lt;?&gt; parent) {

        } 
    });
</code></pre>

<p>The application is throwing a <code>NullPointerException</code> and I can't figure out why.</p>

<p>Here is the logcat snippet:</p>

<pre class="lang-none prettyprint-override"><code>12-14 14:57:31.388: W/dalvikvm(3794): threadid=1: thread exiting with uncaught    exception (group=0x40015560)
12-14 14:57:31.468: E/AndroidRuntime(3794): FATAL EXCEPTION: main
12-14 14:57:31.468: E/AndroidRuntime(3794): java.lang.NullPointerException
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.ArrayAdapter.getDropDownView(ArrayAdapter.java:376)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.Spinner$DropDownAdapter.getDropDownView(Spinner.java:332)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.Spinner$DropDownAdapter.getView(Spinner.java:328)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.AbsListView.obtainView(AbsListView.java:1409)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.ListView.onMeasure(ListView.java:1127)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.View.measure(View.java:8313)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.View.measure(View.java:8313)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at com.android.internal.widget.WeightedLinearLayout.onMeasure(WeightedLinearLayout.java:60)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.View.measure(View.java:8313)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.View.measure(View.java:8313)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.View.measure(View.java:8313)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.os.Looper.loop(Looper.java:123)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at android.app.ActivityThread.main(ActivityThread.java:3683)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at java.lang.reflect.Method.invokeNative(Native Method)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at java.lang.reflect.Method.invoke(Method.java:507)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-14 14:57:31.468: E/AndroidRuntime(3794):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>What am I missing?</p>
