Spinner with on Click Listener

IIRC, you should be using a selected listener, not click:

spinner.setOnItemSelectedListener(new OnItemSelectedListener()

Then you can add the override tag to your selected method.


private String selecteditem;

spinner.setOnItemSelectedListener(new OnItemSelectedListener() 
{    
 @Override
 public void onItemSelected(AdapterView adapter, View v, int i, long lng) {

  selecteditem =  adapter.getItemAtPosition(i).toString();
   //or this can be also right: selecteditem = level[i];
} 
  @Override     
  public void onNothingSelected(AdapterView<?> parentView) 
{         

 }
  }); 

Tags:

Java

Android