title: Android Kotlin onItemSelectedListener for spinner not working
body: <p>I have a spinner with some items (strings).
  I want to add the selected items to a list. I read online that I should use the <code>onItemSelectedListener</code>rather than the <code>onItemClickListener</code>.</p>
  
  <p>I implemented this but I don't know how to complete the step of adding it to the list.</p>
  
  <pre><code>class NewKitListActivity : AppCompatActivity() {
  
  var spinnerArray = arrayOf("Dumbell", "Punching Bag", "Yoga Ball", "Skipping Rope")
  //var spinnerArray = arrayOf(DataService.kitList)
  
  
  
  override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      setContentView(R.layout.activity_new_kit_list)
  
  
  
      val spinner = newKitItemSpinner
      val spinnerArrayAdapter = ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_spinner_dropdown_item, spinnerArray)
      //selected item will look like a spinner set from XML
      spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
      spinner.adapter = spinnerArrayAdapter
  
      spinner.onItemSelectedListener = object : OnItemSelectedListener {
          override fun onItemSelected(parent: AdapterView&lt;*&gt;, view: View, position: Int, id: Long) {
              val selectedItem = parent.getItemAtPosition(position).toString()
              if (selectedItem == "Add new category") {
                  // do your stuff
              }
          } // to close the onItemSelected
  
          override fun onNothingSelected(parent: AdapterView&lt;*&gt;) {
  
          }
      }}}
  </code></pre>
  
  <p>Thanks</p>