title: How can I use onItemSelected in Android?
body: <pre><code>package org.example.mbtiapplication;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.Menu;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.AdapterView.OnItemSelectedListener;
  import android.widget.ArrayAdapter;
  import android.widget.Spinner;
  
  public class MBTITest extends Activity implements OnItemSelectedListener  {
  
      private Spinner firstSpinner;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_mbtitest);
  
          Spinner firstSpinner = (Spinner) findViewById(R.id.spinner1);
          // Create an ArrayAdapter using the string array and a default spinner layout
          ArrayAdapter&lt;CharSequence&gt; adapter = ArrayAdapter.createFromResource(this,
                  R.array.spinnerarraybool, android.R.layout.simple_spinner_item);
          // Specify the layout to use when the list of choices appears
          adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          // Apply the adapter to the spinner
          firstSpinner.setAdapter(adapter);
      }
  
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; parent, View v, int position,
              long id) {
          // TODO Auto-generated method stub
  
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          // TODO Auto-generated method stub      
      } 
  }
  </code></pre>
  
  <p>XML Layout:</p>
  
  <pre><code>&lt;TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" &gt;
  
      &lt;TableRow
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
  
          &lt;TextView
              android:layout_width="120dp"
              android:layout_height="match_parent"
              android:layout_marginLeft="5dp"
              android:gravity="center_vertical"
              android:text="I like to go out more than staying home." /&gt;
  
          &lt;Spinner
              android:id="@+id/spinner1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
      &lt;/TableRow&gt;
  
      &lt;TableRow
          android:layout_width="match_parent"
          android:layout_height="wrap_content" &gt;
  
          &lt;TextView
              android:layout_width="120dp"
              android:layout_height="match_parent"
              android:layout_marginLeft="5dp"
              android:gravity="center_vertical"
              android:textSize="10.5dp"
              android:text="Sensing v Intuition" /&gt;
  
          &lt;Spinner
              android:id="@+id/spinner2"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" /&gt;
      &lt;/TableRow&gt;
  &lt;/TableLayout&gt;
  </code></pre>
  
  <p>I'm a new Android programmer and having trouble with using Spinner, i've tried multiple tutorials and still am confused.  I'd like to know what my next step is here, as far as I know I have set up my spinner in XML, in Java I have identified that spinner, created an ArrayAdapter for said spinner, and specified some options.  I'm not to sure if I have populated the spinner yet or how to manuever with the spinner object.  I'd like to be able to use the spinner object to select one of three options and then keep that value inside of the textview inside of the spinner.  </p>