title: Spinner with on Click Listener
body: <p>I am using spinner that shows error when i am trying to extract the item id of the selected spinner item.
  My Code goes here:</p>
  
  <pre><code>public void dispspi()
    {
      spinner = (Spinner) findViewById(R.id.spinner1);
      ArrayAdapter &lt;String&gt; adap= new ArrayAdapter(this, android.R.layout.simple_spinner_item, level);
  
        spinner.setAdapter(adap);
        spinner.setOnItemClickListener(new OnItemClickListener() {
  
          public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1,int arg2, long arg3) 
          {
              int item = spinner.getSelectedItemPosition();
  
              p=item;
          }
  
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                  long arg3) {
              // TODO Auto-generated method stub
  
          }
  
  
  
      });
    }
  </code></pre>
  
  <p>How to get the item id of the spinner? Any help is appreciated..Thanks in advance</p>