android crash when using setVisibility(View.VISIBLE)
<p>I seem to be getting application crashes at:</p>

<blockquote>
  <p>parent.findViewById(R.id.a_1).setVisibility(View.VISIBLE);</p>
</blockquote>

<p>not sure what im doing wrong</p>

<p>code is below</p>

<p><strong>layouttext.java</strong></p>

<pre><code>    public class layouttest extends Activity {
 private Spinner solvefor; 
 private ArrayAdapter&lt;CharSequence&gt; featuresAdapter; 
 private List&lt;CharSequence&gt; featuresList; 

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        featuresList = new ArrayList&lt;CharSequence&gt;(); 
        featuresAdapter = new ArrayAdapter&lt;CharSequence&gt;(this, android.R.layout.simple_spinner_item, featuresList); 
        featuresAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
        solvefor = ((Spinner) layouttest.this.findViewById(R.id.solvefor)); 
        solvefor.setAdapter(featuresAdapter); 
        featuresAdapter.add("Velocity"); 
        featuresAdapter.add("Time"); 
        featuresAdapter.add("Distance"); 
        solvefor.setOnItemSelectedListener(new MyOnItemSelectedListener());
    }
}
</code></pre>

<p><strong>MyOnItemSelectedListener.java</strong>
    package android.example.layouttest;</p>

<pre><code>import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Toast;

public class MyOnItemSelectedListener implements OnItemSelectedListener {
 private static final int SPINNER_OPTION_FIRST = 0; 
    private static final int SPINNER_OPTION_SECOND = 1;
 public void onItemSelected(AdapterView&lt;?&gt; parent, View view, int pos, long id) {
   switch(pos) { 
         case SPINNER_OPTION_FIRST: { 
          Toast.makeText(parent.getContext(), "0", Toast.LENGTH_LONG).show();
          break;
         } 
         case SPINNER_OPTION_SECOND: { 
          Toast.makeText(parent.getContext(), "1", Toast.LENGTH_LONG).show();
          parent.findViewById(R.id.a_1).setVisibility(View.VISIBLE);
          parent.findViewById(R.id.a_2).setVisibility(View.VISIBLE);
          break;
         } 
  }  
 }   
 public void onNothingSelected(AdapterView&lt;?&gt; parent) {      
   // Do nothing.    
   }
}
</code></pre>
