title: switching activities using spinner
body: <p>i have the below code and i need to fill in the <code>if(pos == 1){??????????}</code> so that i can switch activities when the first position in my spinner is selected. The name of my new acitivity is Route1.java. 
  How would i write the code to switch to Route1.java when position 1 is selected in my spinner.</p>
  
  <pre><code>import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.net.Uri;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemSelectedListener;
  import android.widget.Toast;
  import android.Manifest.permission;
  
  public class MyOnItemSelectedListener extends Activity 
          implements OnItemSelectedListener {
  
      public void onItemSelected(AdapterView&lt;?&gt; parent, 
              View view, int pos, long id) {
          if (pos == 1) {
          } else {
              Toast.makeText(parent.getContext(), 
                      "Your route is "
                      + parent.getItemAtPosition(pos).toString(), 
                      Toast.LENGTH_LONG).show();
          }
      }
  
      public void onNothingSelected(AdapterView parent) {
          // Do nothing.
      }
  }
  </code></pre>
  
  <p>the above class is used in this class </p>
  
  <pre><code>import java.lang.reflect.Array;
  import android.R.array;
  import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.net.Uri;
  import android.os.Bundle;
  import android.view.View;
  import android.webkit.WebView;
  
  import android.widget.AbsSpinner;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemSelectedListener;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.Spinner;
  import android.widget.Toast;
  
  
  public class cnycentro extends Activity {        
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.cnycentro);
  
          Spinner spinner = (Spinner) findViewById(R.id.spinner);
          ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(
                  this, R.array.routes, android.R.layout.simple_spinner_item);
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          spinner.setAdapter(adapter);
  
          spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
      }
  }
  </code></pre>