Spinner:



activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingTop="100dp"
    android:gravity="center_horizontal"
    android:background="#FFFFFF">

    <TextView
        android:id="@+id/result"
        android:layout_width="300dp"
        android:layout_height="50dp"
        android:background="#E91E63"
        android:gravity="center"
        android:text="TextView"
        android:textColor="#FFFFFF"
        android:textSize="20sp" />

    <Spinner
        android:id="@+id/spinnerCountry"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp" />

</LinearLayout>



string.xml in values folder:


<resources>
    <string name="app_name">Spinner</string>
    <string-array name="countries">
        <item>England</item>
        <item>Netherlands</item>
        <item>Belgium</item>
        <item>Germany</item>
        <item>Finland</item>
    </string-array>
</resources>




MainActivity.kt:

package com.example.semend1

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.view.View
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.Spinner
import android.widget.TextView

class MainActivity : AppCompatActivity(), AdapterView.OnItemSelectedListener {

    lateinit var spinner : Spinner
    lateinit var result : TextView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        spinner = findViewById(R.id.spinnerCountry)
        result = findViewById(R.id.result)

        spinner.onItemSelectedListener = this

        var arrayAdapter = ArrayAdapter.createFromResource(
            this,
            R.array.countries,
            android.R.layout.simple_spinner_item
        )

        arrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)

        spinner.adapter = arrayAdapter
    }

    override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
        if (parent != null) {
            result.text = parent.getItemAtPosition(position).toString()
        }
    }

    override fun onNothingSelected(p0: AdapterView<*>?) {

    }
}
