title: Using the event setOnItemSelectedListener the spinner
body: <p>Need to load information from a spinner whichever was selected in my spinner workRequestType. I'm starting to program in java android now, and I'm not sure how to do this procedure.</p>
  
  <p>The research I have done, I need to use setOnItemSelectedListener but do not know how to use. Where I declare this process?</p>
  
  <p>My java code:</p>
  
  <pre><code>spnWorkRequesType.setOnItemSelectedListener(new OnItemSelectedListener() {
  
      @Override
      public void onItemSelected(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
              long arg3) {
  
          String workRequestType = arg0.getItemAtPosition(arg2).toString();
  
          loadCustomServiceSpinner(workRequestType);
      }
  
      @Override
      public void onNothingSelected(AdapterView&lt;?&gt; arg0) {
          // TODO Auto-generated method stub
  
      }});
  
  private void loadCustomServiceSpinner(String workRequestType) {
  
      CustomServiceDBQueries csQueries = new CustomServiceDBQueries();
      customService = csQueries.selectCustomService(workRequestType);
  
      String[] strCustomService = new String[customService.size() + 1];
      strCustomService[0] = "";
  
      int i = 1;
      for (CustomService cs : customService) {
          strCustomService[i] = cs.getCustomServiceName();
          i++;
      }
  
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
              android.R.layout.simple_spinner_item, strCustomService);
      adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  
      Spinner SpnCustomService = (Spinner) findViewById(R.id.SpnCustomService);
      SpnCustomService.setAdapter(adapter);
  
  }
  </code></pre>
  
  <p>Thank you!</p>