我正在使用kotlin,并且尝试使用从微调器中选择的itom做一些事情。我正在使用从另一个类似问题中获得的这段代码,但是根本无法正常工作。有人知道为什么吗?还是我想念的东西?
spinnerBooks.adapter = ArrayAdapter(this,android.R.layout.simple_spinner_item,spinnerBooksArray!!)
spinnerBooks.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onNothingSelected(parent: AdapterView<*>?) {
}
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
val text = parent!!.getItemAtPosition(position).toString()
Toast.makeText(this@AddAuction,"SELECTED: $text",Toast.LENGTH_SHORT).show()
}
}