val spinner = Spinner( this ) var list_of_items = arrayOf ("item1", "item2", "item3" ) val array_adapter = ArrayAdapter( this , android.R.layout. simple_spinner_item , list_of_items) array_adapter.setDropDownViewResource(android.R.layout. simple_spinner_dropdown_item ) spinner. adapter = array_adapter spinner. onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(parent: AdapterView<*>, view: View, pos: Int, id: Long) { //todo : do something } override fun onNothingSelected(parent: AdapterView< out Adapter>?) {} }