title: setOnItemSelectedListener on spinner?
body: <p>i am trying to set onItemSelectedListener on my spinner so if one value get selected from spinner it will show that selected value. my code is,</p>
  
  <pre><code> ArrayList&lt;String&gt; items = getCountries("data.json");
  
      spinner = (Spinner)findViewById(R.id.spinnerStandard);
      ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.second_layout,R.id.txtStandard,items);
      spinner.setAdapter(adapter);
  }
  
  private ArrayList&lt;String&gt; getCountries(String fileName){
  
      JSONArray jsonArray = null;
      ArrayList&lt;String&gt; cList = new ArrayList&lt;String&gt;();
      try {
          InputStream is = getResources().getAssets().open(fileName);
          int size = is.available();
          byte[] data = new byte[size];
          is.read(data);
          is.close();
          String json = new String(data, "UTF-8");
          jsonArray=new JSONArray(json);
          if (jsonArray != null) {
              for (int i = 0; i &lt; jsonArray.length(); i++) {
                  String standard = jsonArray.getJSONObject(i).getString("standard");
                  if(!cList.contains(standard))
                      cList.add(standard);
              }
          }
      }
      catch (IOException e)
      {
          e.printStackTrace();
      }
      catch (JSONException je)
      {
          je.printStackTrace();
      }
     return cList;
  }
  </code></pre>
  
  <p>I've tried googling for all the options and as many other variations as I can think of and can't find any useful results, so I'm obviously missing something.</p>
  
  <p>what will be the correct way of doing this type of situation ?</p>